|
Our Hosting Partners:
65% off at FatCow! iPage Hosting 1&1 Hosting $6.99/mo Free Domain Name If you Order Today! Our CSS Style topics:CSS Code Tutorial Chapters:
visit our other tutorials:
|
Cascading Style Sheets: an Interactive Tutorial
All About Selectors for StylesChapter 3 part 3 (of 3)
Why stop at the p tag? Indenting is kind of useful all around. You can make up an element-less selector name and just forgo the element. All you place is a period . and then your class name. Here's a generic example for indent:
.indent { text-indent: 3em; } Now, we can use that class for all sorts of things. Here's a paragraph and a H1 both using the element-less .indent selector. Download HTML and CSS Web Design Basics Right Now! Or Search for "Web Design Basics" in AppStore!
<p class="indent"> This is a paragraph with indent. </p>
This is a paragraph with indent.
<h1 class="indent">This div has an indent</h1>.
This h1 has an indent.Imagine a selector .g, defined as { color: green; }. Every time you use class="g" in an element the text color would be shown in green. ID selectors are used for special formatting of only a few elements. ID selectors use a # instead of a .. Imagine 3 paragraphs, we'll call them par1, par2, par3. We'll make one red, one orange, and one blue. We could use these styles:
p#par1 { color: red; } ID Selectors can also be element-less: #par1 { color: red; } ...would apply to all tags that specify id="par1".
advertisement
Our Hosting Partners:
The Original $3.15/mo. FatCow Plan - Unlimited Disk Space, Unlimited Transfer, Unlimited E-mails & Site building tools. iPage Hosting 1&1 Hosting $6.99/mo Free Domain Name If you Order Today! |
Copyright © Dave Kristula. All Rights reserved.