Class in html:
- The class is an attribute which specifies one or more class names for an HTML element.
- The class attribute can be used on any HTML element.
Explanation: In the above example CSS styles all elements with the class name “country”.
After clicking on the hide elements button :
Using multiple classes:
HTML elements can have more than one class name, where each class name must be separated by a space.
Explanation: All three headers have the class name “country”, but in addition to that, CHINA also has the class name “middle”, which makes the text center aligned.
Using same class in different tags:
Different tags, like <h2> and <p>, can have the same class name and thereby share the same style.
Explanation: Even if the two elements do not have the same tag name, they can have the same class name, and get the same styling.
- HTML | dir Attribute
- HTML | value Attribute
- HTML | accesskey Attribute
- HTML | oncut Attribute
- HTML | draggable Attribute
- HTML | multiple Attribute
- HTML | rowspan Attribute
- HTML | list Attribute
- HTML | disabled Attribute
- HTML | step Attribute
- HTML | optimum Attribute
- HTML | start Attribute
- HTML | enctype Attribute
- HTML | title Attribute
- HTML <button> value Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ANMOLMITTAL