CSS: Class Attribute
The id attribute is for one element, a singular usage. To define a style for multiple elements, use the class attribute for each of those elements:
<p class="name"> content </p>
In the <style> section, define the style for that class:
p.name { color: red; }
HTML file: |
Displayed by browser: |
<!DOCTYPE html>
<html>
<head>
<style>
p.error { color:red; }
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p class="error">I am different.</p>
<p>This is a paragraph.</p>
<p class="error">I am different too.</p>
</body>
</html>
|
This is a paragraph.
This is a paragraph.
I am different.
This is a paragraph.
I am different too.
|