HTML Class Attribute | 99codes

HTML Class Attribute


html class attribute


Class in html -


1.The class is a quality which determines at least one class names for a HTML component.

2.The class quality can be utilized on any HTML component.

3.The class name can be utilized by CSS and JavaScript to play out specific assignments for components with the predefined class name.

Example -



Following Result -

html class attribute


Explanation:


In the above model CSS styles all components with the class name "nation".

Using The Class Attribute in Java -


JavaScript can get to components with a predetermined class name by utilizing the getElementsByClassName() strategy.


Example -



Following Result -

html class attribute

After Clicking hide Element Button -

html class attribute

Using Multiple Class -


HTML components can have more than one class name, where each class name must be isolated by a space.

Example -

Following Result -

html class attribute


Clarification: All three headers have the class name "nation", however notwithstanding that, CHINA additionally has the class name "center", which makes the content focus adjusted.

Utilizing same class in various labels:


Various labels, as <h2> and <p>, can have a similar class name and in this manner share a similar style.

Example -


Following Result -

html class attribute


Clarification: Even if the two components don't have a similar label name, they can have a similar class name, and get the equivalent styling.



HTML Class Attribute | 99codes HTML Class Attribute | 99codes Reviewed by Arup Roy on May 27, 2019 Rating: 5

No comments:

Powered by Blogger.