HTML Attributes

1) Class Attribute

The HTML class attribute is used to specify a class for an HTML element. it can be used many times in single file.

the file could be CSS or JS file. In below example .fruit will be applied to both div elements.

2) id Attribute

    The HTML id attribute is used to define a unique id for element in webpage. it will be always unique and case sensitive.

    In CSS you can use the # symbol to target an element by its id. The “#myHeader” will be getting applied to <h1> with id “myHeader”.

    Here’s an example of an HTML element with an id attribute:

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Scroll to Top