Wednesday, 9 November 2011

CSS Class

The class selector allows you to set multiple styles to the same element or tag in a document. For example, you might want to have certain sections of your text called out in a different colors from the rest of the text in the document. You would assign your paragraphs with classes like this:


CSS Code :
<style type="text/css">
  p.blue { background-color: #0000ff; }
  p.red { background-color: #ff0000; }
</style> 

Then, when you want to call the various classes you would use the class attribute within the paragraph (<p></p>) tag. Any tag that did not have a class attribute would be given the default style for that tag.

HTML Code :

<p class="blue">
blue background.
</p>
<p>
normal style.
</p> <p class="red">
  red background color.
</p>


No comments:

Post a Comment