Sunday, January 19, 2014

Types - External Style Sheet

This will be very useful when we have so many styles defined. We will want to take all the styles in to a different file. That's what we do in External CSS. We take all the styles in a external file and map it with the html page. 

Example:
We will put the following style in a text file say mystyle.css
<style>
.mystyle1
{
color: green;
background-color: orange;
}
</style>


In our head we will link to the external style sheet using the tag link in header portion
Tag:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>

The names used for user defined styles should not belong to any html tag. We set the style for the tag using the attribute "class".
Example1:

<font
 class=mystyle1> MY STYLE </font>
Result1: 
MY STYLE 

Example2:
<a href="index.php"
 class=mystyle1> MY STYLE </a>
Result2: