HTML 使用 对齐文本对齐标签
我对格式和固定宽度的段落内的文本对齐“对齐”有疑问,因为我希望 HTML 中的段落文本显示完全对齐(就像 MS Word 文件中发生的情况一样)。然而,这并没有发生。我需要修改什么才能实现它?
<pre style="color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: medium; width: 500px; text-align: justify;">
I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). However, this does not happen. What I need to modify to achieve it?
</pre>
编辑:如果我用
标记替换
标记,我的代码可以正常工作。有人可以解释一下为什么吗?也许我错误地使用了标签。
I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). However, this does not happen. What I need to modify to achieve it?
<pre style="color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: medium; width: 500px; text-align: justify;">
I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). However, this does not happen. What I need to modify to achieve it?
</pre>
EDIT: if I replace the <pre>
tag with <p>
tag, my code works properly. Can somebody explain me why? Perhaps I am using a wrong use of <pre>
tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要对齐
-- 编辑 --
您可以使用具有适当样式的
来代替
To justify text in
<pre>
you need to addwhite-space: normal;
in your styles, but in my opinion this misses the point using the<pre>
tag.-- Edit --
Instead of
<pre>
tag you can just use<div>
with appropriate styles. It can imitate<pre>
tag very well and is easier to play with.使用标签:
删除文本前面的所有空格和所有缩进。
Use tags:
Remove all spaces preceding your text, all indentation.