0903 Head First HTML and CSS — Study Log #7
Chapter 8. Styling with Fonts and Colors: Expanding Your Vocabulary
- Customize the fonts in your pages with the
font-familyproperty.- A
font-familyis a set of fonts that share common characteristics. - There are five font families: sans-serif, serif, monospace, cursive, and fantasy.
- A
- Control the size of your fonts with the
font-sizeproperty. - Add color to your text with the
colorproperty. - Affect the weight of your fonts with the
font-weightproperty. - Add even more style to your text with the
text-decorationproperty.- overlines, underlines, and line-throughs
- Underlined text is often confused as linked text by users, so use this property carefully.
- The
font-styleproperty is used to createitalicorobliquetext. Italic and oblique text is slanted. - Always make the last font a generic font like serif or sans-serif, so that the browser can make an appropriate substitution if no other fonts are found.
- FontSquirrel is a great place to find open source, free fonts that you can upload to your server.
- To use a font that your users may not have installed by default, use the
@font-facerule in CSS. - Font sizes are usually specified using
px,em,%, orkeywords.- If you use pixels (“px”) to specify your font size, you are telling the browser how many pixels tall to make your letters.
- You can specify font sizes using
em, which, like percentage, is another relative unit of measure.font-size: 1.2em; emand%are relative font sizes, so specifying your font size usingemand%means the size of the letters will be relative to the font size of the parent element.- You can specify a font size as
xx-small,x-small,small,medium,large,x-large, orxx-largeand the browser will translate thesekeywordsinto pixel values using defaults that are defined in the browser. - Using relative sizes for your fonts can make your pages more maintainable.
- In most cases, the default body font size will be 16 pixels.
- You need to combine the two values into one rule to get both text decorations.
@font-face{
font-family: "EMblema One";
src: url(../journal-copy/EmblemaOne-Regular.woff),
url(../journal-copy/EmblemaOne-Regular.ttf)
}
body{
font-family: Verdana, Geneva, Arial, sans-serif;
font-size: small;
}
h1,h2{
color:#c60;
border-bottom: thin dotted #888888;
}
h1{
font-family: "Emblema One", sans-serif;
font-size: 220%;
}
h2{
font-size:130%;
font-weight: normal;
}
blockquote{
font-style: italic;
}
Word list
- hook
- barb
- tad
- oblique
- bounce
- hex
Chapter 9. The Box Model: Getting Intimate with Elements
line-heightproperty allows you to specify the amount of vertical space between each line of your text.- All elements are treated as boxes: paragraphs, headings, block quotes, lists, list items, and so on. Even inline elements like
<em>and links are treated by CSS as boxes. - Boxes consist of the content area and optional
padding,border, andmargin.- The
marginprovides space between your element and other elements, whilepaddinggives you extra space around your content. - Two other properties also affect the background image:
background-positionandbackground-repeat.- there is a
no-repeatvalue for thebackground-repeatproperty. - The
background-positionproperty sets the position of the image and can be specified in pixels, or as a percentage, or by using keywords like top, left, right, bottom, and center.
- there is a
- For
padding,margins, and evenborders, CSS has a property for every direction: top, right, bottom, and left. - The
border-styleproperty controls the visual style of the border. There are eight border styles available, from a solid line to dotted lines to ridges and grooves. - The
border-widthproperty controls the width of the border. You can use keywords or pixels to specify the width. - The
border-colorproperty sets the color of the border. This works just like setting font colors; you can use color names, rgb values, or hex codes to specify color. - Just as with
margins andpadding, you can specify border style, width, or color on any side (top, right, bottom, or left) - You can create rounded corners on all four corners, or just one corner, or any combinatio.
border-radius:15px;border-top-left-radius:3em;border-bottom-right-ridus:0px;
- The
- An element can’t have multiple
ids; and you can’t have more than one element on a page with the sameid.- an element can have an
idand also belong to aclass - an id selector should match only one element in a page.
- an element can have an
- To select an element by its
id, you use a#(hash mark) character in front of theid(compare this to class, where you use a.[dot] in front of theclassname). - Class names should begin with a letter, but id names can start with a number or a letter. Both id and class names can contain letters and numbers as well as the _ character, but no spaces.
- You can use more than one stylesheet in your HTML. If two stylesheets have conflicting property definitions, the stylesheet that is last in the HTML file will receive preference.
- You can target devices by using media queries in your
<link>element or the@mediarule in your CSS.
#guarantee{
line-height: 1.9em;
font-style: italic;
color: #444444;
font-family: Georgia, 'Times New Roman', Times, serif;
border-color: white;
border-width: 1px;
border-style: dashed;
background-color: #a7cece;
padding: 25px;
padding-left: 80px;
margin: 30px;
margin-right: 250px;
background-image: url(images/background.gif);
background-repeat: no-repeat;
background-position: top left;
}
Word list
- darn
- thick
- indent
- tweak
- dash
query