Horje
How to use The Syntax For Class

To create a class; write a period (.) character, followed by a class name. Then, define the CSS properties within curly braces {}:


Basic Example of using The Syntax For Class

Create a class named "city":
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
.city {
  background-color: tomato;
  color: white;
  padding: 10px;
}
</style>
</head>
<body>

<h2>The class Attribute</h2>
<p>Use CSS to style elements with the class name "city":</p>

<h2 class="city">London</h2>
<p>London is the capital of England.</p>

<h2 class="city">Paris</h2>
<p>Paris is the capital of France.</p>

<h2 class="city">Tokyo</h2>
<p>Tokyo is the capital of Japan.</p>

</body>
</html>

Output should be:

Basic Example of using The Syntax For Class





Related Articles
What is HTML class Attribute HTML class Attribute
How to Use The class Attribute HTML class Attribute
How to use The Syntax For Class HTML class Attribute
How to create HTML Multiple Classes HTML class Attribute
How to create Different Elements Can Share Same Class HTML class Attribute
How to Use of The class Attribute in JavaScript HTML class Attribute

Single Articles
Basic Example of using The Syntax For ClassHTML class Attribute

Read Full:
HTML class Attribute
Category:
Web Tutorial
Sub Category:
HTML class Attribute
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
47


Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_classes_css

Share on: