HTML Tags vs Elements
A start tag, its properties, an end tag, and everything else between make up an HTML element technically. On the other hand, as users can see from the accompanying picture, an HTML tag (whether beginning or ending) is used to designate the start or finish of an element.
However, in everyday speech, the phrases “HTML element” and “HTML tag” are synonymous, meaning that a tag is an essential component and vice versa. As it will describe something on the web page, “tag” and “element” are used interchangeably on this website for the purpose of simplification.
Tag and attribute names are also not case-sensitive in HTML (but most attribute values are case-sensitive). This indicates that in HTML, the tags < P> and < p> both define paragraphs.
However, they are case-sensitive in XHTML, and the tag < P> is distinct from the tag < p>.
The presence of the end tag or closing tag is not required for all items. These are known as void elements, self-closing elements, or empty elements.
Empty HTML Elements
Empty elements (also referred to as self-closing or void components) are not enclosure tags, so we cannot write < hr> some content < /hr> or < br> some content < /br>.
The < br> component, which signifies a line break, is a common example of an empty element. Other popular empty elements include < img>, < input>, < link>, < meta>, < hr>, and so forth.
< p>This paragraph contains < br> a line break.
< imgsrc=”images/sky.jpg”alt=”Cloudy Sky”> < input type=”text”name=”username”>
Nesting HTML Elements
Most HTML elements (excluding empty elements) can include any number of additional components, which are mainly composed of tags, attributes, and content or other elements.
The following example demonstrates various nested items within the < p> element.
< p>Here is some < b>bold< /b> text.< /p> < p>Here is some < em>emphasized< /em> text.< /p> < p>Here is some < mark>highlighted< /mark> text.< /p>
Writing Comments in HTML
Comments are typically inserted that make the source code simpler to read. It may aid another developer (or we in the future when we modify the source code) in understanding what we were attempting to do with the HTML.
HTML Elements Types
Elements are classified into two types: block level components and inline level elements. The former constitute the framework of the paragraph, whereas the latter enhance the information of a block.
A block element also takes up 100% of the available width and is shown with a line break before and after it. An inline element, on the other hand, will take up only the space that it requires.
< div>, < p>, < h1> through < h6>, < form>, < ol>, < ul>, < li>, and so on are the most widely used block-level elements. Inline-level elements that are often used are < img>, < a>, < span>, < strong>, < b>, < em>, < i> < code>, < input>, < button>, and so on.