Home > Web Front-end > HTML Tutorial > Why is it said that inline elements can only accommodate text or other inline elements? _html/css_WEB-ITnose

Why is it said that inline elements can only accommodate text or other inline elements? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:19:40
Original
1111 people have browsed it

css inline

Can inline elements only hold text or other inline elements?
I searched on Baidu for the difference between inline elements and block elements, and the articles I found all said this, but I tested it myself


aaaaaaa


Block elements placed within inline elements will not report an error, and the inline elements will be expanded. This What happened again?
I’m asking for an answer from someone who understands, I’m just a newbie here.

Reply to discussion (solution)

"Inline elements can only hold text or other inline elements". This is usually true, but there are some exceptions.
For example, after the advent of HTML5, the inline element a can contain block elements.

Most inline elements cannot contain block elements.
For example, if you replace the a tag containing a div with span,
an error will be reported during W3C verification. Although the verification reports an error, the browser can still display it.
It’s just that there is no standard definition of this display rule.

One principle of HTML design is to try to make the page elements displayable, as long as it is not a very bad error.
Some rules are not mandatory, just like morals.
You can put block elements inside inline elements, but you shouldn't.

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template