How to use CSS Class and ID Selectors
In other words, to use your new HTML selector, you don't have to add anything else to your HTML code. Just use the tag in the normal way.
However, Class and ID selectors are slightly different.
Using Class Selectors
To set up a Class Selector, the code was this:
You can use this new Rule inside a normal HTML tag. Like this:
Using ID Selectors
You use an ID selector in exactly the same way that you use the Class selectors. The only difference is in the word used when applying the Rule. Instead of Class you use ID:
Wednesday, 8 July 2015
How to use CSS Class and ID Selectors
.ClassSelector {Property: Value}
First, you type a full stop (period). Then you type the name of your Class Selector (which can be anything you want). The Property and Value are then as normal. An example is this:
<H1 Class = "FontOne">My Heading</H1>
When applying your new Class Selector Rule, the word 'Class' is used. You then type an equals sign ( = ), followed by the name you gave your Class Selector. In our case, this was FontOne. But note that the full stop (period) is now missing from the start of the selector name. If you put the full stop in, your Rule won't work. Note that although we've used quote marks around the Class name, this is not strictly necessary. It is recommended, though.
0 comments:
Post a Comment