Home  >  Article  >  Web Front-end  >  Detailed explanation of the difference between tags and elements in HTML_HTML/Xhtml_Web page production

Detailed explanation of the difference between tags and elements in HTML_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:40:121503browse

I believe that many friends who are new to web pages are like me. They don’t understand how elements, tags, and attributes are defined in HTML, and what is the difference between elements and tags. In order to understand it thoroughly, I searched and consulted some information, and now I will write down the conclusion I came to and share it with netizens who are as confused as me:

Many people may not call it a label. I don't understand the concept of what is an element, even I was confused before.
In fact, the concept between the two is still very clear:
For example,

this is a tag;

here is the content

this is an element, which means that the element consists of It consists of a start tag and an end tag, used to contain certain content;
There is a notable exception here, that is,
itself is both a start tag and an end tag, but does not contain any content, so this is just a Label.

1. Element :

HTML web pages are actually text files composed of many various HTML elements, and any web browser can Run HTML files directly. So it can be said that HTML elements are the basic objects that constitute HTML files, and HTML elements can be said to be a general term. HTML elements are defined using HTML tags.

2. Tags :

tags are objects enclosed by angle brackets "" such as , , etc. Most tags appear in pairs, such as
, . Of course, there are a few that do not appear in pairs, such as
,
, etc. The

tag is used to mark HTML elements. The text between the start tag and the end tag is the content of the HTML element.

3. Attributes :

The HTML attributes that provide various additional information for HTML elements are always named with "attribute name = attribute value" Appears in the form of a pair, and attributes are always defined in the opening tag of an HTML element.

Example:

Example title

This is an example page

In this example,

This is a sample page

is an HTML element, where "This is a sample page" is the specific content of the element. and so on are HTML tags, which are tags that constitute HTML elements. The bgcolor="red" in is the attribute of the label, which defines how the label should be configured specifically. In short, you don’t need to pay too much attention to the difference between elements and labels. In actual work, we just refer to them collectively as labels. The attributes are easy to understand. They are parameters that add various additional information or configuration options to HTML tags.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn