what are the 'class' attribute in html

Report
Question
764 views

The class is an attribute which specifies one or more class names for an HTML element. The class attribute can be used on any HTML element. The class name can be used by CSS and JavaScript to perform certain tasks for elements with the specified class name.

Please explain why do you think this question should be reported?

Report Cancel

Applies to

The class attribute is part of the Global Attributes, and can be used on any HTML element.

Use of the class attribute in an HTML document:

<html>
<head>
<style>
h1.intro {
    color: blue;
}

p.important {
    color: green;
}

</style>
</head>
<body>

<h1 class="intro">Header 1</h1>
<p>A paragraph.</p>
<p class="important">Note that this is an important paragraph. :)</p>

</body>
</html>

Thread Reply

Leave an comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>