Home > Article > Web Front-end > Introducing markup and document structure in html
The purpose of marking content with HTML is to give the web page semantics. In other words, you need to give your web page content some meaning that the user agent can understand.
HTML specifies a set of tags to mark content differently. Each tag is a description of what it contains. The most commonly used HTML descriptions are titles, paragraphs, links and pictures. Currently, HTML has a total of 114 tags, but according to the 80/20 principle, using about 25 of them can meet 80% of markup needs.
The latest version of HTML, HTML5, stipulates a new batch of structured tags, which are used to group tags of related content to better standardize the overall structure of the web page. These new tags include 1aa9e5d373740b65a0cc8f0a02150c53, c787b9a589a3ece771e842a6176cf8e9 (navigation), 23c3de37f2f9ebcb477c4a90aac6fffd, 2f8332c8dcfd5c7dec030a070bf652c3, 15221ee8cba27fc1d7a26c47a001eb9b, and c37f8231a37e88427e62669260f0074d.
1. Closure of tags
For each content-containing element (such as title, paragraph, and picture), there are two different ways to give it depending on whether the content it contains is text. They are tagged, one with a closing tag and the other with an unclosing tag.
1.1 Use closing tags for text
Example: 4a249f0d628e2318394fd9b75b4636b1Hello, CSS!473f0a7621bec819994bb5020d29372a
1.2 Use self-closing tags for quoted content
Example: f740ce58840b432cc9712d4d9809069f
Tips:
For self-closing tags, XHTML requirements must be written like this:
XML/HTML Code copies the content to the clipboard
<img src="images/dog.jpg" alt="This is my dog." />
In HTML5, you can omit the last closing slash and write:
XML/HTML CodeCopy content to the clipboard
<img src="images/dog.jpg" alt="This is my dog." >
2. Attribute
Tip: Screen readers used by visually impaired users will read the content of the alt attribute out loud, so be sure to give it The
alt attribute of the tag adds content that people can understand at a glance (or at a glance).
3. Titles and paragraphs
4. Composite elements
HTML not only specifies basic content tags such as titles, pictures, and paragraphs, but also specifies rules for creating lists,
Tables Tags for complex user interface components such as tables and forms. These are so-called composite elements, that is, they are composed of multiple
tags.
5. Nested tags
Simply put, it is to nest one tag inside another tag.
6.HTML5 Template
XML/HTML Code Copy content to the clipboard
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>An HTML Template</title> </head> <body> <!-- 这里是网页内容 --> </body> </html>
7. Block-level elements and inline elements
Document flow effect: HTML elements will They flow from the top of the page to the bottom in the order in which they appear in the markup.
The display attribute of almost all HTML elements is either block or inline. The most obvious exception is the table element, which has its own custom display value.
Block-level elements (such as headings and paragraphs) are stacked on top of each other and arranged down the page, each element occupying its own line. Inline elements (such as links and images) will be juxtaposed with each other, and will be folded to the next line only if there is not enough space to juxtapose.
No matter which HTML element you want to know about, the first question to ask should be: Is it a block-level element, or an inline element? Once you know this, you can anticipate how an element will be positioned in its initial state when writing markup, so that you can further think about how to reposition it using CSS in the future.
There are two things to know:
The block-level element box will expand to the same width as the parent element.
Inline element boxes will shrink-wrap their contents as tightly as possible.
7. Nested elements
The HTML tags are nested in the mark, and the boxes are nested on the screen.
8. DocumentObjectModel
The Document Object Model (DOM for short) observes the elements in the page and each element from the perspective of the browser attributes, resulting in a family tree of these elements. Through the DOM, the interrelationships between elements can be determined. By referencing a specific location in the DOM
in CSS, you can select the corresponding HTML element and modify its style attributes.
CSS The process of manipulating the DOM is to first select an element or a group of elements, and then modify the properties of these elements. After an element is modified through CSS, such as changing the width or inserting a pseudo-element in the markup, these changes will immediately occur in the DOM and be reflected on the page.
In short, it is to build the DOM through HTML tags, and then use CSS to modify the DOM when the page is first loaded and when the user interacts with the page.
The above is the detailed content of Introducing markup and document structure in html. For more information, please follow other related articles on the PHP Chinese website!