CSS Parts

Here are the basic parts of a CSS:

[code lang=”css”]
p {font-size:1em;}
[/code]

Which translates to:

[code lang=”css”]
selector {property:value;}
[/code]

Selectors

Selectors are the ones you target in the HTML document to apply the styles to. Basically, selectors can be:

  • HTML tags: html, body, h1, ul, li, p, etc.
  • Classes: .main-nav, .footer, etc.
  • IDs: #branding, #content, etc.

And many more: http://www.w3.org/TR/CSS2/selector.html

Properties

Properties are attributes of the selector you want to control. For example, you want to control a paragraph’s font size and color, the properties are:

  • Font size = font-size
  • Font color = color

The Full property table: http://www.w3.org/TR/CSS21/propidx.html

Values

Values are the values of the properties. How big or small will be the font size and which color? Say you want to make a paragraph’s font size 24 pixels and colored red, the answers are the values.

[code lang=”css”]
p {
font-size:24px;
color:red;
}
[/code]

Tweak some CSS here: http://cssdesk.com/uGcKH


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *