HTML/CSS - 段落显示源代码中的换行符
由于某种原因,当没有使用
标签时,我的段落会显示换行符!因此,如果我在 HTML 中输入内容并按回车键几次,它就会以这种方式格式化。
我怎样才能防止这种情况发生?我不能让它流动吗?
For some reason my paragraphs are displaying line breaks when there is no <br/>
tag being used! So if I type content into the HTML and hit return a few times it gets formatted that way.
How can I prevent that? Can I not just get it to flow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
浏览器会自动渲染段落标签以进行一些填充,除非您明确将其样式设置为不...这是问题所在吗?
如果是,则 p {padding: 0; margin:0;}
如果没有,请尝试向我们提供一些代码并更好地解释问题所在。
Browsers will automatically render paragraph tags to have some padding unless you explicitly style it not to... is this the problem?
If so, p {padding: 0; margin:0;}
If not, try giving us some of your code and a better explanation of exactly what the problem is.
将其放入您的样式表中:
Put this into your stylesheet:
这两者中的任何一个都可能是问题吗?
The
<pre>
tag will cause white space to display. So will a CSS rule like this:Could either of those be the problem?
如果文本被打断以使其适合,您不能/不应该尝试阻止文本打断。但是,如果您的问题是文本在不需要的点处中断,并且您希望它在更合适的点处中断,请使用以下命令:
使用 nobr 标记将不需要的断点括起来。
并且,在适当的断点处添加以下内容:
If the text is being broken to make it fit, you cannot / should not try to stop the text from breaking. However, if your problem is that the text is breaking at an undesirable point and you would rather have it break at a more appropriate point, use the following:
enclose the unwanted break point with nobr tags.
And, add the following at the appropriate break point: