1. Computing

Discuss in my forum

What is a CSS Class Selector?

By , About.com Guide

A CSS class selector applies to many elements at once, or a sub-set of specific HTML elements. To use them, you need to edit your HTML to define the classes on the HTML elements you want styled. Then you define the style in your style sheet.

Use the class attribute that is available on nearly every XHTML tag.

<p class="bordered">

Or

<div class="bordered">

The class selector is then defined with a period before the class name. You can set a class to work on any XHTML element:

.bordered {
border : 1px solid black ;
}

But you can also set a class selector only on specific elements that have that class. Do this by placing the type selector before the period in the class selector without any spaces:

div.bordered {
border : 2px solid red ;
}

©2013 About.com. All rights reserved.