删除换行符 HTML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18155809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove line break HTML
提问by Ptr13
I'm wondering how to remove the line break in HTML. For example this code would have two Hello Worlds on top of each other. I'm sorry if I'm not good enough at programming to be in this site.
我想知道如何删除 HTML 中的换行符。例如,此代码将有两个相互叠加的 Hello World。如果我在编程方面不够好,无法进入这个站点,我很抱歉。
<p>Hello World</p>
<p>Hello World</p>
回答by David says reinstate Monica
You've got a few options:
你有几个选择:
p {
display: inline-block;
}
Or:
或者:
p {
display: inline;
}
If it's the white-space between the bottom of the first p
and the top of the second p
that you want to remove:
如果要删除的是第一个底部p
和第二个顶部之间的空白p
:
p {
/* top right bottom left */
margin: 0 0 0 0;
}
回答by user1171848
The <p>
tag is a block-level element, meaning that by default it will try to take the entire width of its container. If you must use a <p>
tag, you can change its behavior with CSS using "display:inline." Although, the <span>
tag might work better for what you need, since it is an inline element by default.
该<p>
标签是块级元素,这意味着在默认情况下它会尝试采取其容器的整个宽度。如果必须使用<p>
标签,可以使用 CSS 使用“display:inline”更改其行为。尽管如此,该<span>
标签可能更适合您的需要,因为它默认是一个内联元素。
W3Schools has a lot of information you may find helpful.
W3Schools 提供了很多您可能会觉得有用的信息。