Login
Your Email
Pasword
Home
Write
Trending
History
Liked
Dashboard

How to use The class Attribute in HTML?

The class attribute specifies one or more class names for an HTML element.

Do you have similar website/ Product?
Show in this page just for only $2 (for a month)
Create an Ad
0/60
0/180
The class name can be used by CSS and JavaScript to perform certain tasks for elements with the specified class name. 
To select elements in CSS with a specific class write a period (.) character followed by the name of the class.
E.g:



class Attribute


Use CSS to style elements with the class name "name":


John

John is a Doctor.


Michel

Michel is a Lawyer.





class Attribute in JavaScript
JavaScript can access elements with a specified class name by using the getElementsByClassName() method.
E.g:
  
HTML elements can have more than one class name each class name must be separated by a space.
CONTINUE READING
class Attribute
HTML
HTML
Ayesha
Tech writer at newsandstory