HTML Elements and Attributes

html elements and attributes

1HTML Elements

The HTML element is everything from the start tag to the end tag.

This is the paragraph element. It has an opening tag, content, closing tag.

Unnested Elements

Elements that do not contain any child or parent element are called unnested elements. But that doesn’t usually happen because there is always an element inside another. Like the <title> element inside the <head> element and <body> element inside the <html> element.

Nested Elements

To better understand the nested elements have a look at the same format I provided in the previous chapter and analyze it.

The <html> element defines the whole document. This HTML element contains all other elements inside it.

The <head> element defines the document info. It contains <title> element inside it.

The <body> element defines the document body. It contains heading <h1> element and paragraph <p> element.

The <footer> element defines the post content. It contains one paragraph <p> element.

2HTML Attributes

  • Attributes provides additional information to a particular element.
  • Attributes are always inserted inside the opening tag of an element.
  • They are usually written in name/value pair like name=”value”

Example 1, consider a link element. <a> tag defines a link element like <p> tag defines paragraph element.

But the link element is not clickable yet because it has no link attached to it. To attach a link we use href attribute. href is the attribute name and link is attribute value.

href stands for hyperlink reference. A link in technical terms is also called hyperlink. Now, the clickable text portion is called hypertext when a hyperlink is attached to it using href attribute.

Example 2, consider a heading element. We want that when someone hovers over the heading then he must see a tooltip that says: This is a heading.

To show a tooltip on mouseover we use the title attribute.

There are different attributes for different purposes.
More than one attribute can be specified for a particular element.

Note: We will be exploring every attribute for every HTML element while knowing about the element. This will help you to remember the types of attributes associated with the types of HTML elements.


Please enter your comment!
Please enter your name here