何时使用< span>改为< p&gt ;? [英] When to use <span> instead <p>?

查看:133
本文介绍了何时使用< span>改为< p&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如问题所示,如果我在HTML中添加了一些文本,那么何时应该使用< p> 以及何时应该使用< span>

解决方案

打算描述它包含的内容。

所以,如果你想传达一个段落,那就这样做。



<虽然你的比较并不完全正确。比较直接的比较是


何时使用< div> 作为块级元素,< p>



$ b

A < span> 内联,非常像锚点(< a> ; ),< strong> ,重点(< em> )等。因此,请记住,由于它在html和自然写作中都是默认属性,所以段落会在它自身之前和之后导致中断,如< div>

有时候,当对事物进行样式化时,一个< span> 非常适合给你一些东西钩住CSS,但它是一个没有语义或文体意义的空标签。


As the question indicates, if I have some text that I want to add in the HTML then when should I use <p> and when should I use <span>?

解决方案

You should keep in mind, that HTML is intended to DESCRIBE the content it contains.

So, if you wish to convey a paragraph, then do so.

Your comparison isn't exactly right, though. The more direct comparison would be

When to use a <div> instead of a <p>?

as both are block level elements.

A <span> is inline, much like an anchor (<a>), <strong>, emphasis (<em>), etc., so bear in mind that by it's default nature in both html and in natural writing, that a paragraph will cause a break before and after itself, like a <div>.

Sometimes, when styling things — inline things — a <span> is great to give you something to "hook" the css to, but it is otherwise an empty tag devoid of semantic or stylistic meaning.

这篇关于何时使用&lt; span&gt;改为&lt; p&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆