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
1. Closure of tags
For each element that contains content (such as titles, paragraphs, and images), there are two different ways to tag them, depending on whether the content it contains is text, one is to use a closing tag, and the other is Use non-closing tags.
1.1 Use closing tags for text
Example:
Example:
Tip:
For self-closing tags, XHTML requirements must be written like this:
In HTML5, you can omit the last closing slash and write:
2. Attributes
Tip: Screen readers used by visually impaired users will read the content of the alt attribute aloud, so be sure to add content to the tag's
alt attribute that people can understand at a glance (or at a glance).
3. Titles and paragraphs
4. Composite elements
HTML specifies not only basic content tags such as titles, images, and paragraphs, but also tags for creating complex user interface components such as lists, tables, and forms. These are so-called composite elements, that is, they are It is composed of multiple
tags.
5. Nested tags
To put it simply, it is to nest one tag inside another tag.
6.HTML5 Template
7.块级元素和行内元素
文档流效果:HTML 元素会按照它们各自在标记中出现的先后顺序,依次从页面上方流向下方。
几乎所有HTML 元素的 display 属性要么为 block,要么为 inline。最明显的一个例外是 table 元素,它有自己特俗的 display 值。
块级元素(比如标题和段落)会相互堆叠在一起沿页面向下排列,每个元素分别占一行。而行内元素(比如链接和图片)则会相互并列,只有在空间不足以并列的情况下才会折到下一行显示。
无论你想了解哪个 HTML 元素,第一个要问的问题都应该是:它是块级元素,还是行内元素?知道了这一点之后,就可以在编写标记的时候,预想到某个元素在初始状态下是如何定位的,这样才能进一步想好将来怎么用 CSS 重新定位它。
有两点要知道的:
块级元素盒子会扩展到与父元素同宽。
行内元素盒子会 收缩包裹 其内容,并且会尽可能包紧。
7.嵌套的元素
在标记中嵌套的是HTML标签,而在屏幕上嵌套的则是一个个的盒子。
8.文档对象模型
文档对象模型(简称 DOM)是从浏览器的视角来观察页面中的元素以及每个元素的属性,由此得出这些元素的一个家族树。通过DOM,可以确定元素之间的相互关系。在 CSS 中引用 DOM
中特定的位置,就可以选中相应的 HTML 元素,并修改其样式属性。
CSS 操作 DOM 的过程是先选择一个或一组元素,然后再修改这些元素的属性。通过 CSS 修改了元素后,比如修改了宽度或者在标记里插入了一个伪元素,这些变化会立即在 DOM 中发生,并体现在页面上。
简而言之,就是通过 HTML 标记来构建 DOM,然后在页面初次加载和用户与页面交互时,使用 CSS 来修改 DOM。