Elements, tags and attributes in HTML

Elements, tags and attributes in HTML

Elements - it is defined by a start tag, some content and an end tag.

Syntax- <tagname>content</tagname>.

E.g- <h1>Hello World!</h1>

Tags - HTML tags are like keywords that define how a web browser will format and display the content. And all tags have predefined meanings in the browser.

There are lots of tags available in HTML like- h1 to h6 tag, <p>, <img>, <a>, <span> tag etc.

some tags are self-closing tag that doesn’t need closing tag eg- <img>, <br>, <hr> etc.

Attributes - It provides additional information about the elements. Each element or tag can have attributes, which define the behavior of that element. It is always used with a start tag and it has some property name and value.

E.g- <img src=”pic.jpg“ alt=”my picture”>. In this example, src and alt are the attributes of <img> tag.