|
| |||
MAIN MENUCascade Style Sheets (CSS) IntroductionCSS Selectors Where CSS definitions are embed in HTML page CSS attributes CSS & MySpace CSS SELECTORSSelectors are the names that you give to your different styles.In the style definition you define how each selector should work (font, color etc.). Then, in the body of your pages, you refer to these selectors to activate the styles. For example:
In this case B.headline is the selector. The above example would result in this output:
There are three types of selectors:
TAG SELECTORSThe general syntax for an HTML selector is:HTMLSelector {Property:Value;} For example:
HTML selectors are used when you want to redefine the general look for an entire HTML tag. CLASS SELECTORSThe general syntax for a Class selector is:.ClassSelector {Property:Value;} For example:
Class selectors are used when you want to define a style that does not redefine an HTML tag entirely. When referring to a Class selector you simply add the class to an HTML tag like in the above example (class="headline"). SPAN and DIV as carriers Two tags are particularly useful in combination with class selectors: <SPAN> and <DIV>. Both are "dummy" tags that don't do anything in themselves. Therefore, they are excellent for carrying CSS styles.
<DIV> has a particular importance for layers. Since layers are separate blocks of information. <DIV> is an obvious choice when defining layers on your pages. ID SELECTORSThe general syntax for an ID selector is:#IDSelector {Property:Value;} For example:
ID selectors are used when you want to define a style relating to an object with a unique ID. This selector is most widely used with layers (as in the above example), since layers are always defined with a unique ID. GROUPED SELECTORSMost often selectors will share some of the same styles, for example, being based on the same font.In these cases, rather than defining the font for each and every selector, one by one, you can group them, and thus assign the font to all the selectors at once. Look at this example, made without grouping:
As you can see, the only style that varies is the font-size. In the next example we have grouped the selectors, and defined the common styles at once.
Less to type, easier to change and guaranteed to be the same for all styles. CONTEXT DEPENDANT SELECTORSIt is possible to make selectors that will only work in certain contexts.For example, you can define a style for the <B> tag that is only triggered if the text is not only bold but also written in italics. For example, the style should be in effect here:
but not here :
THE SYNTAX Simply adding a normal style to the <B> tag is done like this:
Adding a context dependent style, like the one described above is done like this:
We simply separated the contextual <I> tag from the <B> tag with a space. USING GROUPED AND CONTEXT DEPENDENT SELECTORS AT THE SAME TIME: It is possible to use context dependent and grouped selectors at the same time. For example, like this:
In the example the font-size of 16 pixels is in effect on: 1) All <B> tags enclosed by <I> tags 2) All headlines classes. 3) sublines classes enclosed by <B> tags. | ||||||||||||||||||||||||||||
| go home Contact tables graphics Profile videos Extended network graphics Animated icons | ||||||||||||||||||||||||||||



