Elements


Elements

Elements make up an HTML file. These components are in charge of constructing web pages and defining the content on those pages. A start tag < tag name >, a closing tag < /tag name >, and material added between them make up an element in HTML.

The start tag, the end tag and the information in between these two tags taken together is known as an element.

Syntax

< tagname > content to be displayed< /tagname >

Void element

Some elements in HTML do not require a start tag or an end tag; these elements are referred to as Void elements or empty elements because they do not contain content or an end tag. Unpaired tags are another name for these elements. < br > (represents a line break), < hr > (represents a horizontal line), and so on are Void elements.

Syntax

Nested HTML Element

We can insert one element into another element, such elements are known as nested HTML elements.

Syntax

< tagname1 >
    < tagname2 >Content to be displayed < /tagname2 >
< /tagname1 > 

Block-level elements

These elements divide a page into cohesive sections and structure the main part of a web page. For example, a block-level element begins with a new line and spans the entire width of the web page, from left to right. These elements can include both block-level and inline elements.

Inline elements

Inline elements distinguish one part of a text from another and provide it with a specific function. These elements do not begin with a new line and instead take the width that is required. Inline elements are typically used in conjunction with other elements.

Example No.1:

<html> <head> <title>Knowledge2life</title> </head> <body> <p>Knowledge2life paragraph</p> </body> </html>

OUTPUT

Knowledge2life paragraph

Example No.2:

<html> <head> <title>Knowledge2life</title> </head> <body> <h1>Website <i>Knowledge2life</i> </h1> <p> <u>welcome to Knowledge2life</u> </p> </body> </html>

OUTPUT

Website Knowledge2life

welcome to Knowledge2life