Great Templates

FEATURED WEB TEMPLATES

Amazon Books

Learn PHP

PHP Training
Zend Cert Training Zend Certified Engineer Zend PHP Pro

HTML Hyper Text Markup Language: CSS Cascade Style Sheet Guide

CSS Cascaded Style Sheets Guide?

Below are 28 very common Style Sheet commands. You can put together a myriad of different looks with these. However, this is a list of less than half of those available. At the end, I\'ll give a couple of links to full lists of commands. But I\'ll bet these become your work-horses. Most of the other commands are overly specific.

  1. The FONT/TEXT Definitions:
    1. font-family
      • Denotes typeface.
      • H2 {font-family: arial}
    2. font-style
      • Denotes the style of the text.
        Use normal, italic, small caps, or oblique for commands.
      • H3 {font-style: small caps}
    3. font-size
      • Denotes the size of the text.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
      • H4 {font-size: 20pt}
    4. font-weight
      • Denotes text presence.
        Specify in extra-light, light, demi-light, medium, bold, demi-bold, or extra-bold.
      • A:link {font-weight: demi-light}
    5. font-variant
      • Denotes a variant from the norm.
        Specifiy normal and small-caps
      • H2: {font-variant: small-caps}
    6. text-align
      • Justifies the alignment of text.
        Specify as left, center, or right
      • H1 {text-align: center}
    7. text-decoration
      • Lets you decorate the text (duh).
        Specify as italic, blink, underline, line-through, overline, or none.
      • A:visited {text-decoration: blink}
    8. text-indent
      • Denotes margins. Most often used with the

        . Make sure you use


        Specify in inches (in), centimeters (cm), or pixels (px).
      • P {text-indent: 1in}
    9. word-spacing
      • Denotes the amount of spaces between words.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
      • P {word-spacing: 10px}
    10. letter-spacing
      • Denotes space between letters.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
      • P {letter-spacing: 2pt}
    11. text-transform
      • Denotes a transformation of the text.
        Specify capitalize, uppercase, lowercase.
      • B {text-transform: uppercase}
    12. color
      • Denotes color of text.
        See here for a few color codes. If you use the six digit hex codes, make sure you place a hash mark (#) in front.
      • H3 {color: #FFFFFF}

  2. The MARGIN/BACKGROUND Commands
    Note! When used with the "BODY" tag these commands affect the entire page!

    1. margin-left
    2. margin-right
    3. margin-top
      • Denotes space around the "page".
        Specify in points (pt), inches (in), centimeters (cm), or pixels (px).
      • BODY {margin-left: 2in}
      • P {margin-right: 12cm}
      • BODY {margin-top: 45px}
    4. margin
      • Denotes all three margin commands above in one command.
        The pattern follows top, right, and then left.
      • P {margin: 3in 4cm 12px} (note no commas or semi-colons)
    5. line-height
      • Denotes space between lines of text.
        Specify in points (pt), inches (in), centimeters (cm), or pixels (px), or percentage (%).
      • TEXT {line-height: 10px}
    6. background-color
      • Denotes page\'s background color.
        Specify the color in hex or word codes, or use "transparant"
      • BODY {background-color: #ffffff}
    7. background-image
      • Denotes the background image for pages.
        Specify the image you want through that image\'s URL.
      • BODY {background-image: http://www.page.com/dog.jpg}
    8. background-repeat
      • Denotes how the image will tile.
        Specify repeat-x, repeat-y, or no-repeat.
      • BODY {background-repeat: repeat-y}
    9. background-attachment
      • Denotes how the image will react to a scroll.
        Specify scroll, or fixed.
      • BODY{background-attachment: fixed}

  3. The Positioning/Division Definitions:
    These commands come into play when you begin working with text and image positioning. Note these examples are given using a specific item.

    1. position
      • Denotes the placement of an image or a division of the page.
        Specify absolute for specific placement, or relative for a relative placement to other images.
    2. left
      • Denotes amount of space allowed from the left of the browser screen when positioning an item.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
    3. top
      • Denotes amount of space allowed from the top of the browser screen when positioning an item.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
    4. width
      • Denotes width of image or page division.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
    5. height
      • Denotes height of image or page division.
        Specify in points (pt), inches (in), centimeters (cm), pixels (px), or percentage (%).
    6. overflow
      • If the item is too large for the height and width specified, this tells the page what to do with the overflow.
        Specify visible, hidden, or scroll.
    7. z-index
      • Denotes an item\'s position in the layering structure. The lower the number, the lower the layer. An image marker with a 20 would go overtop of an image marked with a 10.
        Specify by number.
      • -

What It All Looks Like

Here\'s the Style Sheet from this page:

</p> <p><!--<br /> BODY {background: #FFFFFF}<br /> A:link {color: #80FF00}<br /> A:visited {color: #FF00FF}<br /> H1 {font-size: 24pt; font-family: arial}<br /> H2 {font-size: 18pt; font-family: braggadocio}<br /> H3 {font size:14pt; font-family: desdemona}<br /> --></p> <p>


What If I Want The Same Tag Handled Different Ways?

What you do it assign different "classes" of tags. Real simple. Look here:

H3.first {font-size: 20pt; color: #FF00FF}
H3.scnd {font size: 18pt; color #DD00FF}

See what I did? I labeled the H commands separately by adding a dot and then a suffix. I used "first" for the first type and "scnd" for the second type. You can use what ever you want. I like these determinants. When you place them on your page, you do this in the text:

This will be affected as outlined in "H3.first"


This will be affected as outlined in "H3.scnd"


One Style Sheet--Many Pages

First off, create a style sheet as you did above. This will be the only thing on the page. No commands this time. You will make the file so that if I wanted, I could just copy and paste what you have right into my own commands. Which is just about what you will be asking the computer to do.
The Style Sheet will be a simple text file with a .css suffix. Let\'s say you name your style sheet "fred". Its name would become "fred.css". The suffix is required for browsers to recognize it as a style sheet rather than a simple mesh of letters.

Place this command on your page to call for the Style Sheet:

Here\'s what\'s happening:
  • LINK tells the browser something must be linked to the page.
  • REL=stylesheet tells the browser that this linked thing is relative to this page as a style sheet.
  • HREF="---" denotes where the browser will find the style sheet.
  • TYPE="text/css" tells the browser that what it is reading is text that will act as a Cascading Style Sheet. If the document isn\'t text with a .css suffix - no dice.

Every page that contains this command will be affected by the one style sheet you created and placed in your directory. One sheet - many pages.


Can I Use These Style Element on Individual Items?

Yes you can. They simply sit inside the TAG you are working with. Just make sure to denote them using the STYLE command. Since they sit inside another command as just a defining command, they require no /STYLE. In that position, they affect only what you say they will rather than the entire page. Like so:

affected text

Follow this format and you can define a style for just about any HTML TAG. There\'s also a method of setting up classes of items that works pretty much the same way. See just below for the link.


 


Learn PHP | Zend Certified Engineer | Zend PHP Pro | PHP Web Apps | Web Hosting Service | Low Cost Domain Names | Great Templates | Great Books | Testimonials | Tech.Articles | TOS | AUS | Home | Linux Apache MySQL PHP