Monday, October 11, 2010

CSS Class

In CSS, classes allow you to apply a style to a given class of an element. To do this, you link the element to the style by declaring a style for the class, then assigning that class to the element.

CSS Class Syntax
You declare a CSS class by using a dot (.) followed by the class name. You make up the class name yourself. After the class name you simply enter the properties/values that you want to assign to your class.
.class-name { property:value; }

If you want to use the same class name for several elements, but each with its own style, you can prefix the dot with names of HTML elements.
html-element-name.class-name { property:value; }
CSS Class Example:
<style type="text/css">
font-family:Verdana, Arial, Helvetica, sans-serif;

font-family:Verdana, Arial, Helvetica, sans-serif;
<h1 class="section">This is Heading</h1>
<p class="css-section">This is Paragraph</p>
This results in:

This is Heading

This is Paragraph

No comments:

Post a Comment