Question - Three selectors: h1, .warning and #footer, what they do ?
Answer -
An element points at a HTML-tag somewhere on your page. In the example above we want to style the
-tag. Note that using an element like that affects all tags with that name, so using p { margin-left: 100px; } gives all
-tags a left-margin.
Using a class is just as simple. When writing .your_class you style all tags with a class with the name “your_class”. In the example above we have .warning which will style e.g.
and
, that is, any element with the class warning. Classes are used when you want to style just a few of your tags in a way, perhaps you want some of your links red? Add a class to all those links.
You need one more building block: the id. This time you style an element with the attribute “id” set to the id you have chosen. Ids work exactly like classes except for one thing; you can only have one id with a certain name in each of your HTML documents. In the example above we style
Comment(S)
Show all Coment
Leave a Comment
|