|
|
In the past, any formatting of web pages had to be done through numerous HTML tags such as <BIG>, <SMALL>, <EM>, <I>, <U>, and <FONT>. These were awkward to use because all the formatting was in the same file, intermixed with the content. CSS allows you to achieve pages that look the way YOU want, with much less work. CSS is supported in IE 3+ and Netscape 4+. CSS can be placed in three places. The first is within a tag as an attribute. Ex: <P STYLE="color:green;">This is a green paragraph.</P> This is a green paragraph. This is not a very good way to do it, as the formatting is still part of the HTML. CSS can also be put in a STYLE tag in the HEAD of a document. In this case, you need to specify what element you are referring to, using either an element type (P, Body, H3, etc.), Class (a grouping of specific elements) or an ID (one specific instance of an element). Ex: <STYLE TYPE="text/css"> Let's see the result. This is a H1This is a normal H2This is a H2 of class background--> element asdf This method is better, since all the formatting is together in the HEAD. Notice that the normal H2 showed up as maroon, as did the forecolor of H2.background. That is because this page also uses a linked CSS. You can save CSS instructions in a separate file, and link it in using a LINK tag in the HEAD. Here is the tag used in this page. <LINK REL="stylesheet" TYPE="text/css" HREF="../../css/wws.css"> This tag, or something close to it, is in almost every page of WWS. One change to that file changes the formatting to all of WWS. These three methods can conflict, especially when you are linking in several files. CSS has the word Cascading because there are special rules for which instructions get precedence. Rules with ! important between the value and the semicolon have precedence over normal rules. Then, a rule which applies to an ID has precedence over a rule for a Class, which has precedence over a rule for a standard HTML element. Finally, if two rules have the same weight, the last one entered is used.
|
|