Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 为什么我的HTML代码块添加了多余的结束段落分隔符?_Css_Html - Fatal编程技术网

Css 为什么我的HTML代码块添加了多余的结束段落分隔符?

Css 为什么我的HTML代码块添加了多余的结束段落分隔符?,css,html,Css,Html,我有这个标记: CSS HTML (或者,如果您是HTML/CSS专家,可能是预览版),在上面显示的HTML部分的末尾有多余的一行或段落分隔符。其他“旁白”/注释不显示该行为。以下是其中之一: <aside style="margin:4px;padding:4px;border:1px solid forestgreen;"> That is to say, 40-50 years ago at the time Twain wrote it, which was in the 1

我有这个标记:

CSS HTML
(或者,如果您是HTML/CSS专家,可能是预览版),在上面显示的HTML部分的末尾有多余的一行或段落分隔符。其他“旁白”/注释不显示该行为。以下是其中之一:

<aside style="margin:4px;padding:4px;border:1px solid forestgreen;">
That is to say, 40-50 years ago at the time Twain wrote it, which was in the 1880s; in other words, the time period covered in "Huck Finn" is the 1830s and 1840s, between the War of 1812 and the Civil War.
</aside>

也就是说,40-50年前吐温写这本书的时候,是19世纪80年代;换句话说,《哈克·芬恩》所涵盖的时间段是19世纪30年代和19世纪40年代,即1812年战争和内战之间。

我需要做些什么来消除尾随符?

正如@sdcr在评论中告诉你的,这个问题的产生是因为
旁边的
特别有一个
p
元素,而你在底部看到的空间是由于段落的
页边距底部的

为了避免看到它,只需从
旁边的
最后一段中删除
页边距底部

aside p:last-child {
    margin-bottom: 0;
}

查看它对JSFIDLE的更新:

您可能指的是
p
元素从浏览器样式表中获得的默认
margin-bottom
。如果你不喜欢,请覆盖它。@B.ClayShannon,因为你在
上有边框样式,而只有一个里面有
(你抱怨的那个)。@user2864740:“HTML5取消了ID与文档唯一性的限制”–与你第一次评论

。@user2864740:“试试hellohibye

foo。”–为什么有人要这样做?只需在
div
之前关闭
p
,这是唯一有意义的事情,而整个问题首先就可以避免。“第一段在div之前隐式关闭”–我知道这一点……但是如果没有关闭应该关闭的元素的草率性,你就不会一开始就陷入混乱。忽略关闭

,即使在大多数情况下允许==错误的建议IMHO。这会使代码无效,因为这样你就有一个没有打开的关闭

<代码>
,这是无效的。另外,p边距可见的原因是因为aside元素上的边框防止它从aside中折叠出来。
<aside style="margin:4px;padding:4px;border:1px solid forestgreen;">
That is to say, 40-50 years ago at the time Twain wrote it, which was in the 1880s; in other words, the time period covered in "Huck Finn" is the 1830s and 1840s, between the War of 1812 and the Civil War.
</aside>
aside p:last-child {
    margin-bottom: 0;
}