Home Surf the web Anonymously My public bookmarks phpshift.info Promote yourself free Free 1GB Online Storage

CSS: Lesson 1

Rules of CSS

You must learn how to write CSS correctly, or else your code will not work. If you miss one semi-colon, your entire stylesheet will fail to work. One must use the correct grammar, or else nothing will make sense.

  • All rules must be enclosed in {curly braces}
  • Authors must include a semi-color ; at the end of every line.
  • CSS is case sensitive; TABLE is not the same as table
  • comments are written beginning with /* and end in */.
/*For example, this is a CSS comment. These words will not be read by any user-agents, including web browsers and search engines*/

Selectors

To refer to different sections of an HTML document we use selectors. They can either be used to refer to general HTML elements, such as <div> or <body>, or specifc things in the .html document, such as when a user hover their mouse over links found in the unordered list inside the div section representing the "header" of the page. For example, if we want to specify all <table> elements in the document, we could use the table CSS selector, as seen in the example below:

table {
background-color: blue
}

Now all <table> elements in the HTML document will have a blue background colour. We could also select other HTML elements, such as <strong>.

strong {
color: red;
font-size: 150%;
}