We're sorry, but this discussion has just been closed to further replies.
In order to get a full understanding of how CSS styles HTML, we’ll need to get a basic understanding of HTML and XHTML (Extensible Hypertext Markup Language). The biggest difference between HTML and XHTML is that XHTML is more strict and less forgiving than HTML. For example, in HTML it is okay to write, while in XHTML, it will return an error. Therefore, it is always in best practice to create your HTML in all lowercase tags. Also in XHTML, all tags must be closed.
For example:<p> </p>, <br/>,<hr/>, <img src="#"/>.
It is always in best practice to write in XHTML. There are 2 different types of tags: inline and block-level. Inline tags allow multiple instances of that tag to be placed on the same line (a, em, span, strong, img). Block-level elements allow only one instance per line, placing the next tag below the one before it (table, p, h1, div, ul, li, ol).
The selector is the HTML tag, id (#), or class (.) being styled. The styles are stated within curly braces. The property is what is being styled (margin, padding, font-size, etc) and the value] is the value of the property (10px, 100%, #000000). It is always best to end a "property: value;" declaration with a semicolon. This can make or break your styles.
An id (#) refers to the identity of the element being styled. I can only be used once per page, therefore, it is best to use it to describe an area of the page ( #wrapper, #header, #footer, #bodyContent ). A class (.) refers to any HTML tag that is receiving special treatment. For example: p.quote, a.externalLink, li.highlighted. While HTML tags can receive more than one class separated by a space, it can only receive one id. <p class="class1 class2 class3" id="id1"> </p>
Classitis is a term for the overuse of unnecessary classes on an element. Such as in the example below, where the h1 is the only tag within the div.
<div> <h1 class="headerText">Heading</h1>
</div>
Divitis is a term for the overuse of unnecessary divs in the markup. For example: <div> <div align="center"><h1>Heading</h1></div>
</div>
The<div align="center">adds unnecessary markup to the HTML, when it can just be applied to the h1 CSS style. Font Control Below are style properties used in styling text:
font: normal 12px/18px Verdana, Arial, Helvetica, "Century Gothic", sans-serif;
The order being: (font-weight or font-style) font-size/line-height font-family.Tags: css
© 2009 Created by Toon on Ning. Create Your Own Social Network