-
-
Notifications
You must be signed in to change notification settings - Fork 2
HTML Classes
Hridaya edited this page Feb 4, 2021
·
1 revision
The HTML class attribute is used to specify a class for an HTML element.
Multiple HTML elements can share the same class.
The class attribute is often used to point to a class name in a style sheet. It can also be used by JavaScript to access and manipulate elements with the specific class name.
For Example, we have three
elements with a class attribute with the value of "city". All of the three
elements will be styled equally according to the .city style definition in the head section.
class="city"
To add multiple classes you write them like this:
class="city main"
The class name can also be used by JavaScript to perform certain tasks for specific elements.
JavaScript can access elements with a specific class name with the getElementsByClassName()
method
HTML Intermediate Tutorials
© 2021, Learn Earn & Fun, Inc.
- Home
- HTML Styles
- HTML Colours
- HTML Forms
- HTML Tables
- HTML IFrames
- HTML Symbols(UTF-8) Reference
- HTML Emojis(UTF-8) Reference
- HTML Video Embeds