Pages

Wednesday, December 26, 2012

CSS Id and Class


<!DOCTYPE html>
<html>
<head>
<style>
.center
{
text-align:center;
}
</style>
</head>

<body>
<h1 class="center">Center-aligned heading</h1>
<p class="center">Center-aligned paragraph.</p> 
</body>
</html>


ANOTHER EXAMPLE

<!DOCTYPE html>
<html>
<head>
<style>
#para1
{
text-align:center;
color:red;

</style>
</head>

<body>

<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>




<!DOCTYPE html>
<html>
<head>
<style>
p.center
{
text-align:center;
}
</style>
</head>

<body>

<h1 class="center">This heading will not be affected</h1>
<p class="center">This paragraph will be center-aligned.</p> 
</body>
</html>




No comments:

Post a Comment