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 | value Attribute
- HTML | dir Attribute
- HTML | required Attribute
- HTML | pattern Attribute
- HTML | onblur Attribute
- HTML <button> value Attribute
- HTML | onmousedown Attribute
- HTML | option value Attribute
- HTML | multiple Attribute
- HTML | reversed Attribute
- HTML | input value Attribute
- HTML | readonly Attribute
- HTML | onscroll Attribute
- HTML | oncut Attribute
- HTML | draggable 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