Table of Contents
回复内容:
Home Web Front-end H5 Tutorial HTML 哪些元素不能有后代元素?编写时应注意哪些?

HTML 哪些元素不能有后代元素?编写时应注意哪些?

Jun 07, 2016 am 08:42 AM
html5

还有哪些元素有顺序要求?

对了 HTML5讲的是 内容类别 。

回复内容:

你说的这个叫做 void element:
w3.org/TR/html5/syntax.

HTML5 里面的 void element 是这些:
area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr

void element 写的时候,只需要 open tag,不需要 close。

但是注意,你看到源码里面有的 tag 没有 close,不一定就是 void element,因为还有一个东西叫做 tag omission: 8 The HTML syntax 除了void element之外,你还问了哪些标签是必须按照顺序的,我举例几个:
html->head->body
table->thead->tbody->tr/td->tfoot
ul->li
dl->dt->dd
等等。。 在我的知识领域,只有单个标签的有这种限制,比如
HTML 哪些元素不能有后代元素?编写时应注意哪些?。至于注意事项,就两点:

1,别拼错标签名。之前见过一个问题,那哥们遇到了很奇葩的 HTML 问题,浏览器渲染多了很多空白,还到处问哪里出错了。其实是标签名写错了。

2,某些标签是没法相互嵌套的。比如:a 标签下面不能嵌套 a,form 标签里面不能嵌套 form。此外就是 inline 属性的标签不能嵌套 block 属性的标签。比如:span 包裹一个 p 标签。当然也有万能标签,a 虽然是 inline 属性,但是除了 a 之外,随便套。div 是 block 的万能套标签,span 是 inline 属性的无意义标签。如果你要用 html 结构模拟什么东西,最好就是用一大群的 span 来模拟,这样模拟出来的东西,无论放到 inline 还是 block 标签下面都 OK。 HTML标签还是蛮灵活的。至于哪些元素不能有后代元素,我也无法全部所全,这方面知识我想查阅W3C有关于HTML方面的规范会更全面,也更权威。我一般情况下行内元素标签不套块元素标签。 最近在把自家产品做改版
需要一套代码覆盖全部终端
需要屏幕阅读
需要盲操
才发现w3c真是目光高远啊
不考虑语义还是图样 不好意思,我不会这个问题~
因为我写的时候,都是无脑叠加div。除了文字,链接,控件,其他所有都是用div~
然后inline元素,基本不套div(也就是block元素),我的习惯就是,所有inline元素都是最里面的元素,我刚才尝试了下,好像td这种inline标签里嵌套div会出问题的。所以把所有的inline元素都放到black里面~ 终归不会出现什么问题把。

假如哪里错了,指出~ 谢谢。 说个跑题的
这个不必刻意记住 利用编辑器的代码提示 找个好用的ide 写的多了也就记住了
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

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.

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

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

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

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

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

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

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

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

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

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

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

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

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

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

See all articles