问题描述
我是CSS的新手,我的问题是:我想在新行中添加一条水平线.
I am new to css and my question is this: I want a horizontal line in a new line.
所以我认为这是个好主意:
So I thought this would be a good idea:
<p><hr/></p>
但是它给出了:
<p></p>
<hr>
<p></p>
为什么?
谢谢您的回答.您说对了,这个问题很神秘.下次我将使用jsfiddle进行更具体的说明^^
推荐答案
HTML < p>
元素是一个块级元素,只能包含短语内容.即文本和标记文本包含.
The HTML <p>
element is a block-level element that can only contain Phrasing Content; that is, text and the markup text contains.
< hr>
元素表示段落元素之间的主题中断,并且在一个段落内包含一个 是没有意义的.该标准规定,在< hr>
块级元素之前,将生成隐式的</p>
,以关闭任何打开的< p>
元素.
The <hr>
element represents a thematic break between paragraph elements, and it makes no sense to have one inside a paragraph. The standard stipulates that before the <hr>
block-level element, an implicit </p>
is generated that closes any open <p>
elements.
简而言之,您要执行的操作违反了段落和水平规则的语义.
In short, what you're trying to do violates the semantics of paragraphs and horizontal rules.
这篇关于取得< hr>用< p>换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!