Class properties in HTML
In HTML, class properties are used to identify one or more class names for HTML elements.
In HTML, class
properties are used to identify one or more class names for HTML elements. Class names can be used in CSS or JavaScript to perform certain tasks for elements named that class. In CSS, to select an element with a special class, add a dot (.) And then enter the class name.
Examples use CSS to style all elements with the class name 'city'
Hanoi
Hanoi is the capital of Vietnam.
Paris
Paris is the capital of France.
Tokyo
Tokyo is the capital of Japan.
The results displayed will look like the following.
The class attribute applies to many elements
Note:
class
properties can be used with any HTML element.- The class name distinguishes between uppercase and lowercase letters.
Use class properties in JavaScript
JavaScript can access certain class-named elements with getElementsByClassName()
For example, when a user clicks a button, hiding all elements with the class name is 'city'.
Use multiple layers in HTML
HTML elements can use multiple class names, each with a space separated by a space. For example, you can style elements with the 'city' and 'big' layers.
London
Paris
Tokyo
Same class but different cards
Different cards like
good
can use the same class name (and have the same style).
Hanoi
Hanoi is the capital of Vietnam.
Previous lesson: Block and inline elements in HTML
The following article: id attribute in HTML
You should read it
- Class selector in CSS
- The id attribute in HTML
- ID selector in CSS
- Attribute Selector - Attribute Selector in CSS
- Attributes in HTML
- Storage class in C / C ++
- HTML color code - color code table in html
- Style properties in HTML
- Style HTML with CSS
- Pseudo-Class in CSS
- Class (Class) in C #
- How to Crash a Class in College