|
For example, you want to apply a CSS style to the paragraph tag. Some sample HTML would be:
<p>This is my paragraph text.</p>
In the CSS stylesheet, you just write the name of the HTML element and put your styles in curly brackets, like this:
p {
color: blue;
}
So, the CSS selector for an HTML element is just the HTML element name.
For example, we might have a class called TxtColoured applied to a paragraph tag, the HTML being:
<p class="TxtColoured">This is my paragraph text.</p>
To apply styling to the class, we write the class name in the stylesheet with a fullstop in front, like this:
.TxtColoured {
color: blue;
}
So, the CSS selector for a class is the class name with a fullstop in front.
The id selector is used to identify a specific element on the page, e.g. a specific paragraph. Example HTML would be:
<p id="ThirdParagraph">This is my third paragraph.</p>
To apply styling to an id, we write in the stylesheet the id name with a hash character in front as follows:
#ThirdParagraph {
color: blue;
}
So, the CSS selector for an id is the id name with a hash character in front.
Back to CSS How To Guides | See also: CSS Web Design
Visit LowPrices.co.uk for Your UK Shopping
Compare Prices at LowPrices.co.uk |
All Content ©2020 WebRef.eu |