What Are HTML Elements?
An HTML element is a component of an HTML document that tells a web browser how to structure and interpret a part of the HTML document. HTML elements can contain formatting instructions, semantic meaning, and content.
For example, HTML elements are used to denote document parts such as headers, paragraphs, and footers and to embed content such as hyperlinks, text, and images. Although HTML can be used to provide formatting instructions, HTML standards strongly encourage using CSS for this purpose instead.
An HTML element is defined by a start tag, some content, and an end tag.
How many types of Elements:-
There are three kinds of HTML elements::-
Normal elements
Raw text elements
Void elements.
1. Normal elements:-
it usually has both a start tag and an end tag, although for some elements the end tag, or both tags, can be omitted. It is constructed similarly:
a start tag (
<tag>
) marking the beginning of an element, which may incorporate any number of HTML attributes;some amount of content, including text and other elements;
an end tag, in which the element name is prefixed with a slash:
</tag>
.Example:-
`<!DOCTYPE html> <html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>`
2. Raw text elements:-
it is also known as text or text-only elements are constructed with:
a start tag (in the form
<tag>
) marking the beginning of an element, which may incorporate any number of HTML attributes;some amount of text content, but no elements (all tags, apart from the applicable end tag, will be interpreted as content);
Example:- The `<title>` element, which must not contain other elements (including markup of text), only *plain* text.
3. Void Element:-
it is also sometimes called empty elements, single elements or stand-alone elements that only have a start tag (in the form <tag>
), which contains any HTML attributes. They may not contain any children, such as text or other elements.
Two common void elements are <br />
(for a hard line break, such as in a poem or an address) and <hr />
(for a thematic break)
Example:-
The <br>
tag defines a line break, and is an empty element without a closing tag:
<p>This is a <br> paragraph with a line break.</p>
You have to know:
HTML is Not Case Sensitive
HTML tags are not case-sensitive: <P>
means the same as <p>
.
Thank you for reading ๐
If you enjoyed this article or found it helpful, give it a thumbs-up ๐
Feel free to connect