Use a CSS Class to Style an Element

What is Class in Html/CSS:
The class global attribute is a space-separated list of the case-sensitive classes of the element. Classes allow CSS and Javascript to select and access specific elements via the class selectors or functions.The class attribute specifies one or more classnames for an element. The class attribute is mostly used to point to a class in a style sheet.  class selector can apply to multiple elements.
Note: Class is always start with Period(.)

To Use a CSS Class to Style an Element follow the below steps:

Step1: Open your text editor or Notepad.
Step2: Write the below code in your editor or notepad.
Step3: Save your document in etc.html format.
Step4: Open in Browser.

For Example:

<html>
<head>
<title> your web page title name </title>
<style>
.h1{
color: red;
}
.p{
color: blue;
}
</style>
</head>
<body>
<h1> your first heading </h1>
<p> your paragraph </p>
</body>
</html>


Output:

















Please Share To Other:

Post a Comment

0 Comments