开发者

What are alternatives to the span-element? [duplicate]

This question already has answers here: Alternative to using span? [duplicate] (4 answers) 开发者_JAVA百科 Closed 9 years ago.

say you are working without the <p> element in HTML. How would you stylize a simple text with css? What HTML-Tag would you take? I always used <span>, but now I saw that span should always be used to group inline-elements (for example <p>). And thats not the case in my example.

Thanks, phpheini


First you should look whether some tag matches semantically. For instance, you might have a text which requires emphasis, in which case em is the best choice. Another case is if you have a heading, which you could style with h1, ..., h6. Always first consider this option!

If there really is no meaning to the text you want to style, or at least, not a meaning supported by css, you can use either span (for inline text) or div (for block elements).


You're free to use any tag you wish... (Within reason); Just make sure it's semantic.

Just a few you could use: <div> <em> <strong> <small> <pre>


<div>

Div tags are basically <span> tags for block elements instead of inline elements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜