Elements in HTML
The HTML element usually goes in pairs, including the opening tag, closing tag, and the content inside the two tags.
content
The HTML element is everything from the opening tag to the closing tag.
Example of HTML element
Learn HTML programming
HTML is a hypertext markup language.
- Open card is
- The content of the element is' Learn HTML programming 'and' HTML is hypertext markup language. '
- Close tag is
and
HTML elements without content are called empty elements. Empty element has no closing tag, for example
(used for line breaks).
Nested HTML elements
HTML elements can be nested (this element is in another element)
All HTML documents contain nested HTML elements.
The following example has 4 HTML elements.
Learn HTML programming
HTML is a hypertext markup language.
Explain the example
- Element
Defined for both texts, with open tags
and the closing tag is
. The content of this element is another element (that is
).
Learn HTML programming
HTML is a hypertext markup language.
- Element
Identify the entire body of the text, starting with the opening tag
and end with a closing tag
,
the content is 2 other HTML elements(
).
Learn HTML programming
HTML is a hypertext markup language.
- Element
,
the content is Learn HTML programming.
Learn HTML programming
- Element Identify the paragraph, including the opening tag and the closing tag is
,
the content is HTML is the hypertext markup language.
HTML is a hypertext markup language.
Don't forget the closing card
Although some HTML elements are still displayed correctly even if you forget the closing tag, the browser will still display the same way as the closing tag, for example, below.
Learn HTML programming
HTML is a hypertext markup language.
But don't rely too much on this because in other cases, it may cause an error when you forget the closing card.
Empty HTML element
Empty HTML elements are elements that do not contain content.
is an empty element, has no closing tag and is used to break the line.
Empty elements can 'close' at the opening tag like this
/>
HTML5 is not required to close the empty element. But if you want more rigorous validation or want your XML parsers to be readable, it's best to close all HTML elements properly.
Tags marked with uppercase and lowercase letters
HTML tags are not necessarily lowercase or uppercase,
good
are the same.
The HTML5 standard is not required to use lowercase letters, but W3C recommends lowercase letters in HTML and requires lowercase text for more demanding documents like XHTML.
Previous article: Basic examples of HTML
The following article: Properties in HTML
You should read it
May be interested
- Attributes in HTMLproperties are used to add information to elements in html.
- Title in HTMLit is very important to use the title to show the text structure. heading (html) in html is identified by tags marked from to, of which the most important title is the least important.
- Text in HTMLthe element in html is used to define a paragraph of text.
- Style properties in HTMLthe style attribute specifies the style for the html element.
- Format text in HTMLformat elements in html help determine the style and importance of text.
- Quote elements in HTMLquote elements in html. the element in html is used to define short excerpts. the browser usually inserts quotation marks before and after the element.