assigning style to html object using id property

It is also possible to assign a css class to an HTML object using the ID property of html object. To do that, the css class name is prefixed with a hash (#) sign. In the following example, the css classes are defined whose name are the name set in ID properties of HTML objects

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style>
#myhead1
{
color:#900;
}
#myhead2
{
color:#63C;
}
#myhead3
{
color:#0F0;
}

#par1
{
  color:#090;
}

#par2
{
  color:#3F6;
}



</style>


</head>
<body>

<h1 id="myhead1"> This is heading 1 </h1>
<h2 id="myhead2"> this is heading 2 </h2>
<h3 id="myhead3"> This is heading 3 </h3>

<p id="par1">
This is web engineering course, and we have started cascaded style sheets
</p>


<p id="par2">
This is second P tag. This is web engineering course, and we have started cascaded style sheets
</p>

</body>
</html>

 

Add a Comment

Your email address will not be published. Required fields are marked *