Chapter 6
The class Selector
The
class selector is used to specify a style for a group of elements. Unlike the
id selector, the class selector is most often used on several elements.This allows you to set a particular style for many HTML elements with the same class.
The class selector uses the HTML class attribute, and is defined with a "."
In the example below, all HTML elements with class="center" will be center-aligned:
Example :4
<!By using class selector >
<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>
Output is:
Center-aligned heading
Center-aligned paragraph.
No comments:
Post a Comment