Tagged: HTML elements
- May 22, 2018 at 1:34 pm #322
An HTML element is a combination of the initial tag, the end tag, and the content.
Examples of HTML elements:
Start Tag Content of the Element End Tag
This is a paragraph.
This is bold text.
Note: most items can also have attributes (attributes will be discussed in detail in the next chapter of this tutorial).
About the final tag
The browser will correctly display the HTML element even if you forget to specify the end tag.
HTML is the language of “forgiving errors”, but there is a more severe version of the language (XHTML), in which skipping the end tag will be considered an error.
<p> Paragraph without a closed tag
<p> Another paragraph without a closed tag
Most elements can be nested inside each other (that is, another element can be located in the content of one element).
For example, by enclosing the
<i>element in the
<b>element, you can make the text bold and italic at the same time.
In XHTML, elements should always be nested correctly (incorrectly: <i> <b> </ i> </ b>, correctly: <i> <b> </ b> </ i>), in HTML the nested elements are not properly nested are considered an error.
<i> <b> This text is italic and bold at the same time. </ b> </ i>
Empty HTML elements
Elements that can not have content are called empty elements , for example
<hr>are empty elements.
In XHTML, empty elements must have a closing tag (<br /> , <hr / >), in the absence of closing HTML tag is not considered an error, and the browser will correctly display these elements.
In which register to write tags?
HTML is not case sensitive, which means that the
<b>tag will be interpreted by the browser as well as the
<B>tag, in XHTML tags can be written only in the lower layout.
Despite the fact that HTML does not insist on strict syntax, we recommend in advance to work out certain rules for writing code (for example, if you write tags in the lower layout, then do so always).
Code is not following any rules unpleasant to read and difficult to understand.
<! - 1. Code written in "free style" -> <HR> <P ID = par1 > This is the first paragraph <br /> <i> <p> This is the second paragraph </ I> <HR> <! - 2. The code following the XHTML rules -> <hr /> <p id = "par1" > This is the first paragraph </ p> <br /> <p> <i> This is the second paragraph </ i> </ p > <hr />
You must be logged in to reply to this topic.