Tuesday, December 21, 2010

Easy CSS/HTML Page Part 3

We should discuss how CSS influences HTML, and vice versa. CSS has style organizations put together in classes and id's.

  • class = .nameofclass { }
  • id = #nameofid { }
A class uses a period before the name of the class. An id uses a hash mark (pound symbol) before the name of the id. The class form styles many types of areas, whereas the id form usually styles one specific area. HTML calls (tells the browser to look in the CSS for) these classes and id's, with this form:

  • <div class="nameofclass"></div>
  • <div id="nameofid"></div>
So the CSS needs a class or id name that the HTML can call, to style a box's position, size, or look. If the CSS class or id was missing or wrong, the browser would ignore the call, and display the box/area however it can. The same goes for a missing/wrong class/id within the HTML.

These class or id names also shorten the HTML code (which is already pretty long). We can call the same class many times for different areas, with just one name. Then, those areas are styled with the exact same position, size, and look.

No comments:

Post a Comment