Elements, Tags and Attributes

Elements, Tags and Attributes

Tags - tags are used in HTML code so that browsers can distinguish between text, headings, audio and videos. If we don’t write text using the tags, the browsers can not understand whether the text is a paragraph, heading or anything. Tags are of two types. One is closing tags and the other is self-closing tags. Closing tags are required to close but the self-closing tags are not required to close. We can also give the class or the id to the tags so that they can be targeted in CSS to make the content of the tags beautiful. The content of the tags is written inside or between the tags. Div, p, img, a, video, audio etc. are some examples of closing tags. br is an example of the self-closing tag.

Element - We know that the content is embedded inside or between the tags. The content including tags is called an element. Element is of the same type as what is of the tag. Elements are of two types. One is block-level elements and another is inline elements. Block-level elements take the space of the whole row but inline element take only that space which is required. div, p are some examples of block-level elements. span is an example of an inline element.

Attribute - Attribute is an extra property which is given to the element. The attribute is written inside the opening tag and after the name of the tag. The class and the id are also attributes. The src and the alt are the attributes in the img tag where src stands for source, alt stands for alternate and img stands for the image.

Did you find this article valuable?

Support Rishabh Chaturvedi by becoming a sponsor. Any amount is appreciated!