问题描述
我有一个问题,在< h1>
标记后删除换行符,因为每次打印,它后添加一个换行符, code>< h1> Hello World!< / h1> < h2> Hello Again World!< / h2> 打印如下:
I am having a problem with removing linebreaks after the <h1>
tag, as everytime it prints, it adds a line break straight after it, so something like <h1>Hello World!</h1> <h2>Hello Again World!</h2>
prints out like this:
Hello World!
Hello Again World!
我不确定什么标签我需要在CSS中更改,但我希望它的一些填充或边距
I am unsure on what tags I need to change in CSS, but I expect it's something to do with the padding or margins
我也希望在可能的情况下保持垂直填充。
I also want to keep the vertical padding if at all possible.
推荐答案
听起来像你想将它们格式化为内联。默认情况下, h1
和 h2
是块级元素,跨越行的整个宽度。您可以将其更改为与css内联,如下所示:
Sounds like you want to format them as inline. By default, h1
and h2
are block-level elements which span the entire width of the line. You can change them to inline with css like this:
h1, h2 {
display: inline;
}
这里有一篇文章解释了 / code>和
inline
:
Here's an article that explains the difference between
block
and inline
in more detail: http://www.webdesignfromscratch.com/html-css/css-block-and-inline/
为了保持垂直填充,使用
inline-block
,如下所示:
To maintain vertical padding, use
inline-block
, like this:
h1, h2 {
display: inline-block;
}
这篇关于在< h1>之后删除换行符标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!