HTML element is the unit of building a web page, which is composed of HTML tags and HTML attributes. HTML elements are also the basic units in web pages.
Like other markup languages, the key to HTML is tags. HTML tag is the most basic unit in HTML language, and HTML tag is the most important part in HTML language. Tags are coded symbols used to distinguish and separate different parts of content and tell the browser what kind of content it is processing. The names of most HTML tags accurately describe their purposes and the content types they mark, such as titles, paragraphs, lists, images and so on.
HTML tags are enclosed in a pair of angle brackets (
& ltp & gt
In HTML, tag names are case-insensitive, that is, they are case-insensitive.
Most tags are used in pairs: the open tag [(start tag, also called start tag)] is used to indicate the beginning of the content segment, and the closed tag [close tag, also called end tag, end tag)] is used to indicate the end of the content segment. For example, a paragraph begins with a start tag.
& ltp> Hello, world! & lt/p & gt;
It can be seen that the syntax of HTML tags is as follows, and there are two forms (paired and unpaired):
& lt tag name > content
& lt label name >
HTML tags should be enclosed in two angle brackets;
Most of them are closed (closed means that there should be a/mark ending at the end of the tag), and there can be content between the start tag and the end tag;
Labels are case-insensitive, and lowercase is recommended by the standard.
These two tags and everything between them constitute an element. The tag name is the element name.
There are three forms of HTML elements:
Leading and trailing tags must be paired elements, such as
The start tag must appear, and the end tag is optional, for example
Elements with only opening tags and no closing tags, such as
Among them,
An element can be preceded by some attributes to provide more information about the element. Attributes consist of attribute names followed by attribute values. For example:
& ltp class="greeting "> Hello, world! & lt/p & gt;
This paragraph has a class attribute with a value of greeting. Attributes of elements are separated from elements by English half-width spaces. The value and name of an attribute are connected by an equal sign (=), and the value can be enclosed in a pair of quotation marks, double quotation marks or single quotation marks as long as they match ("? The attribute value of' is invalid), of course, quotation marks can also be used in HTML, but if the attribute value contains spaces, quotation marks must be used. A few attributes don't need attribute values in HTML, which acts as boolean attributes [attributes without values are called minimized attributes]. Like tagnames, property names are case-insensitive. Attribute values are usually case-insensitive, but sometimes they are, especially when the attribute value data is used for script reference or submitted to the server, and some values may need to be capitalized. Even so, for consistency, lowercase is lowercase.
The opening tag of an element can have multiple attributes, which are also separated by spaces. Attributes are only allowed in the opening tag (or a single self-closing tag of an empty element). Some elements must specify certain attributes, while others are dispensable.
As you can see, the general syntax of HTML attributes is as follows:
& lt tag name attribute name 1= "attribute value" attribute name 2= "attribute value" ... attribute name N= "attribute value" > content.
HTML attributes generally appear in HTML tags, and HTML attributes are a part of HTML tags.
Tags can have attributes that contain additional information. The value of an attribute is usually in quotation marks (sometimes without quotation marks).
A tag can have one or more attributes or no attributes;
Attributes usually appear in pairs by attribute name and value.
The following figure illustrates the components of the element.
Some people call elements tags (such as "P tags"). It's one thing to remember elements, but it's another to remember tags (whether they are opening tags or closing tags). For example, the head element always exists, even if it has no opening tag or closing tag.