Pages

CSS Id

The id and class Selectors

In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" 


The id Selector

The id selector is used to specify a style for a single, unique element.
The id selector uses the id attribute of the HTML element, and is defined with a "#".
The style rule below will be applied to the element with id="para1":

Example


#para1
{
text-align:center;
color:red;

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>

No comments:

Flag Counter
| Copyright © 2013 Remote Tutor