Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.
What is the difference between html Element and Attribute?
Experience Level: Junior
The element consists of 3 parts:
- opening tag,
- and closing tag
The opening tag can have zero or more attributes.
Each attribute consists of name and value.
Have a look at the following example:
If you break it down to separate parts:
- The whole block is element
<p class="some-class" id="my-paragraph">is the opening tag
- The Some paragraph is the content
</p>is the closing tag
class="some-class"is the first attribute where the attribute name is class and the attribute value is some-class
id="my-paragraph"is the second attribute where the attribute name is id and the attribute value is my-paragraph
Related HTML job interview questions
What is a <div> tag?HTML Junior
What is a basic structure of the HTML page?HTML Junior
How can you display HTML code of a web application?HTML Junior
What is HTML used for?HTML Junior