|
||||||||||||||||||||||
CSS Introduction : SelectorsAnother useful set of functions in CSS are selectors. So far we've been using basic element selectors. E.g. What if you've got two <h2> tags, and you want to apply a different style to each of them? How can you change the properties between the two?
Class and ID SelectorsClasses and IDs are very specific selectors. In HTML they look like this:<h1 class="pagetitle"> <h1 id="note">Simply, in HTML they are attributes added to each tag.
In CSS, you can now specify these tags types more precisely. H2 class PagetitleH2 id NoteSPAN class CodeThis would make <h2 id="note"> have red text, and <h2 class="pagetitle"> have size 16pt, Verdana faced text. Both <h1> tags, but different styling. The 'code' class would apply to any tag with the class='code' attribute, making the font green. Tags can have a Class, and an ID. e.g. <h1 class="pagetitle" id="note">. In this case, the <h1> tag would be size 16pt, Verdana, and Red. This is because ID's are more specific then classes. The order has nothing to do with it. Because ID's are more specific, their attributes are used ontop of the preference of other selectors.
Pseudo-Class Selectors:Hover :Visited :Active are all examples of Pseudo class selectors, and for most browsers they only apply to <a> hyperlinks.
All of ^ that means.. A bit like the links on mkv25.net. Now, go on.. try it! Use this code below, and put it into a HTML document.
<body>
Author: Markavian |
tutorial Pages
|
|||||||||||||||||||||