What are the classifications of html5 elements?
html5元素可以分为两个类别:1、“块级元素”;该种元素会独占一行,总是在新行上开始,元素的宽度、高度以及外边距和内边距等都可以控制。2、“内联元素”;该种元素和其他元素会在同一行上显示,元素的宽度、高度以及外边距和内边距都不可以改变。
本教程操作环境:windows7系统、HTML5版、Dell G3电脑。
HTML 标签(元素)可以分为两个类别,分别是块级元素和内联元素(也叫行内元素)。
块级元素
块级元素最主要的特点是它们自己独占一行,块级元素中最具代表性的就是
、
块级元素一般都具有特定的语义,可以使代码的可读性更强。
块级元素的主要特征如下所示:
不管是否使用换行标签
,块级元素总是在新行上开始;块级元素的宽度、高度以及外边距和内边距等都可以控制;
如果省略块级元素的宽度,那么它的宽度默认为当前浏览器窗口的宽度;
块级元素中可以包含其它的内联元素和块级元素。
内联元素
内联元素也可以称为行内元素,行内元素中最常用的是,此外还有、、、、、、、、、
、<cite>、<dfn>、<kbd>和<var>等。</var></kbd></dfn></cite>
内联元素往往带有某种特殊的显示效果,可以代替部分 CSS 样式,非常实用,例如:
和标签可以修饰字体;
和两个标签分别用来定义下标文本和上标文本。
行内元素的主要特征如下所示:
行内元素和其他元素会在同一行上显示;
行内元素的宽、高以及外边距和内边距都不可以改变;
行内元素的宽度就是其中内容的宽度,且不可以改变;
内联元素中只能容纳文本或者其他内联元素。
对于行内元素的使用,需要注意如下几点:
设置宽度 width 无效;
设置高度 height 无效,但可以通过 line-height 来设置行高;
可以设置 margin 外边距,但只对左右外边距有效,上下无效;
设置 padding 内边距时,只有左右 padding 有效,上下则无效,需要注意的是元素范围是增大了,但是对元素周围的内容是没影响的;
可以通过 display 属性将元素在行内元素和块级元素之间进行切换。
扩展知识:重点说明两个标签
1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
2) 标签
HTML 中的标签是一个内联元素,可以对 HTML 文档中的内容进行修饰,此标签不会为文档内容提供任何视觉效果,但可以与 CSS 结合使用来美化网页。
下面通过一个示例来演示标签的使用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
结果展示:
标签本身并没有什么特殊效果,通常需要借助 CSS 来改变内容的样式,比如字体、颜色、大小、边框、背景等。
说明:那些不被推荐的 HTML 内联标签,比如 、、 等,建议使用 + CSS 样式来代替;但是那么具有明确语义的内联标签,比如 、、、<em>、<i>、<s> 等,还是应该坚持使用,这些标签比 <span> 更加具有语义,更有助于搜索引擎理解页面内容。</span></s></i></em>
The above is the detailed content of What are the classifications of html5 elements?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
