Formatting Text Using CSS
Font Properties font-family font-size font-weight font-style font-variant font
Font Properties Font-Family font-family p { font-family: Arial, sans-serif; } generic font families - sans-serif, serif, monospace, cursive, fantasy
Font Properties Core Fonts Sans Serif Arial ,  Arial Black ,  Trebuchet ,  Verdana Serif Georgia ,  Times New Roman Monospace Courier New ,  Andale Mono Cursive Apple Chancery ,  Comic Sans ,  Snell Fantasy Impact ,  Stencil
font-size h1 { font-size: 1.5em;} Font Properties Font-size
Font Properties Font-size pt  -  points 1/72 inch pc  -  (1 pica = 12 points) mm  -  millimeters cm  -  centimeters in  -  inches em  –  size of M ex  -  height of lowercase “x” px  -  varies with display resolution %   percentage values Absolute Units Relative Units
Font Properties Font-size body { font-size: 16pt; } h1 {font-size: 200%; } The font size of the h1 type would be 32 points
Font Properties Font-size xx-small   x-small   small   medium Keywords Large x-Large   xx-Large
Font Properties Font-size There are two relative keywords:  Larger and Smaller <span style=&quot;font-size:  larger &quot;> Larger </span> <span style=&quot;font-size: smaller &quot;> Smaller </span></p> Used to shift the size of text relative to the parent element.
font-weight h1 { font-weight: bold;} Font Properties Font-weight
font-weight Possible values include: normal, bold, bolder, lighter Or (not often used) 100, 200, 300, 400, 500,  600 , 700, 800, 900 Font Properties Font-weight
font-style h1 { font-style: italic;} Possible values are normal, italic, oblique, inherit Font Properties Font-style
font-variant h1 { font-variant: small-caps;} Possible values are normal, small-caps, inherit Font Properties Font-variant
Font Properties Single rule font:  style weight variant  size /line-height  font-family h1 { font: 1em serif;} h1 { font: oblique bold small-caps 1.5em/1.8em Georgia, &quot;Times New Roman&quot;, serif ;}
font-color h1 { font-color: gray;} h1 { font-color: #666666;} h1 { font-color: #666;} Font Properties Font-color
Font Properties Descendant, Child and Sibling Selectors Example What it does li em { color: olive;} Selects only <em> tags when they are included in <li> p > em {color: olive;} Selects only <em> tags when their parent is a <p> called a &quot;child selector&quot; h1 + p Targets only <p> tags when they follow an <h1> tag called a &quot;sibling selector&quot;
Font Properties ID Selectors Example What it does <li id=&quot;salelist&quot;>Tshirt<li> Unique ID  selector used in a tag. li#salelist  { color: red; } When this is added to the style sheet, the text enclosed in this <li> tag would be red. #salelist  { color: red; } The selector can be shorted to just this.
Font Properties ID Selectors Example What it does #sidebar li { color: blue; } Unique ID  selector defined in the style sheet. Any line item that appears in the element designated as sidebar would be blue.
Font Properties Class Selectors Example What it does <p class=&quot;special&quot;> Class selectors can be used multiple times in a document. p.special { color: orange; } Using this in the style sheet indicates that all paragraphs with the class special would be orange. .special { color: orange; } All tags with the class=&quot;special&quot; selector would be orange.
Font Properties Text Adjustments - Line Height line-height p { line-height: 2em;} Possible values are number, percentage, normal, inherit
Font Properties Text Adjustments - Indents text-indent p { text-indent: 2em;} Possible values are percentage, length measurement, inherit
Font Properties Text Adjustments - alignment text-align p { text-align: left;} Possible values are left, right, center, justify
Font Properties Text Adjustments - decoration text-decoration p { text-decoration: underline;} Possible values are none, underline, overline, line-through, blink, inherit
Font Properties Text Adjustments - Capitalization text-transform p { text-transform: capitalize;} Possible values are none, capitalize, lowercase, uppercase, inherit
Font Properties Text Adjustments - Spacing letter-spacing p { letter-spacing: 1.2em;} Possible values are length measurement, normal, inherit
Font Properties Text Adjustments - Spacing word-spacing p { word-spacing: 1.2em;} Possible values are length measurement, normal, inherit

Formating Text Using CSS

  • 1.
  • 2.
    Font Properties font-familyfont-size font-weight font-style font-variant font
  • 3.
    Font Properties Font-Familyfont-family p { font-family: Arial, sans-serif; } generic font families - sans-serif, serif, monospace, cursive, fantasy
  • 4.
    Font Properties CoreFonts Sans Serif Arial , Arial Black , Trebuchet , Verdana Serif Georgia , Times New Roman Monospace Courier New , Andale Mono Cursive Apple Chancery , Comic Sans , Snell Fantasy Impact , Stencil
  • 5.
    font-size h1 {font-size: 1.5em;} Font Properties Font-size
  • 6.
    Font Properties Font-sizept - points 1/72 inch pc - (1 pica = 12 points) mm - millimeters cm - centimeters in - inches em – size of M ex - height of lowercase “x” px - varies with display resolution % percentage values Absolute Units Relative Units
  • 7.
    Font Properties Font-sizebody { font-size: 16pt; } h1 {font-size: 200%; } The font size of the h1 type would be 32 points
  • 8.
    Font Properties Font-sizexx-small x-small small medium Keywords Large x-Large xx-Large
  • 9.
    Font Properties Font-sizeThere are two relative keywords: Larger and Smaller <span style=&quot;font-size: larger &quot;> Larger </span> <span style=&quot;font-size: smaller &quot;> Smaller </span></p> Used to shift the size of text relative to the parent element.
  • 10.
    font-weight h1 {font-weight: bold;} Font Properties Font-weight
  • 11.
    font-weight Possible valuesinclude: normal, bold, bolder, lighter Or (not often used) 100, 200, 300, 400, 500, 600 , 700, 800, 900 Font Properties Font-weight
  • 12.
    font-style h1 {font-style: italic;} Possible values are normal, italic, oblique, inherit Font Properties Font-style
  • 13.
    font-variant h1 {font-variant: small-caps;} Possible values are normal, small-caps, inherit Font Properties Font-variant
  • 14.
    Font Properties Singlerule font: style weight variant size /line-height font-family h1 { font: 1em serif;} h1 { font: oblique bold small-caps 1.5em/1.8em Georgia, &quot;Times New Roman&quot;, serif ;}
  • 15.
    font-color h1 {font-color: gray;} h1 { font-color: #666666;} h1 { font-color: #666;} Font Properties Font-color
  • 16.
    Font Properties Descendant,Child and Sibling Selectors Example What it does li em { color: olive;} Selects only <em> tags when they are included in <li> p > em {color: olive;} Selects only <em> tags when their parent is a <p> called a &quot;child selector&quot; h1 + p Targets only <p> tags when they follow an <h1> tag called a &quot;sibling selector&quot;
  • 17.
    Font Properties IDSelectors Example What it does <li id=&quot;salelist&quot;>Tshirt<li> Unique ID selector used in a tag. li#salelist { color: red; } When this is added to the style sheet, the text enclosed in this <li> tag would be red. #salelist { color: red; } The selector can be shorted to just this.
  • 18.
    Font Properties IDSelectors Example What it does #sidebar li { color: blue; } Unique ID selector defined in the style sheet. Any line item that appears in the element designated as sidebar would be blue.
  • 19.
    Font Properties ClassSelectors Example What it does <p class=&quot;special&quot;> Class selectors can be used multiple times in a document. p.special { color: orange; } Using this in the style sheet indicates that all paragraphs with the class special would be orange. .special { color: orange; } All tags with the class=&quot;special&quot; selector would be orange.
  • 20.
    Font Properties TextAdjustments - Line Height line-height p { line-height: 2em;} Possible values are number, percentage, normal, inherit
  • 21.
    Font Properties TextAdjustments - Indents text-indent p { text-indent: 2em;} Possible values are percentage, length measurement, inherit
  • 22.
    Font Properties TextAdjustments - alignment text-align p { text-align: left;} Possible values are left, right, center, justify
  • 23.
    Font Properties TextAdjustments - decoration text-decoration p { text-decoration: underline;} Possible values are none, underline, overline, line-through, blink, inherit
  • 24.
    Font Properties TextAdjustments - Capitalization text-transform p { text-transform: capitalize;} Possible values are none, capitalize, lowercase, uppercase, inherit
  • 25.
    Font Properties TextAdjustments - Spacing letter-spacing p { letter-spacing: 1.2em;} Possible values are length measurement, normal, inherit
  • 26.
    Font Properties TextAdjustments - Spacing word-spacing p { word-spacing: 1.2em;} Possible values are length measurement, normal, inherit