我怎么写上标文字?

时间:2015-10-12 18:55:57

标签: html superscript

我有一个应用程序,其中包含大量的上标中的数字或字母。我注意到了

 X<span style="vertical-align: super;">3</span>

只是在图3周围使用sup标记,我的应用中都会产生X3

但只有sup代码会在SO上产生X3。这是否意味着我应该坚持后者?有什么区别,优点和缺点,如果有的话?

修改:我已检查http://www.w3schools.com/tags/tag_sup.asphttp://www.w3.org/TR/html-markup/sup.html。我似乎没有看到任何差异。

2 个答案:

答案 0 :(得分:5)

只需使用<sup>super</sup>

正如您在W3C的参考文献中看到的那样,sup标签只是CSS的例程:

sup {
    vertical-align: super;
    font-size: smaller;
} 

优点:它适用于所有平台,这就是它的目的。还为屏幕阅读器和其他机器人提供语义含义。

缺点:有些人只是喜欢在CSS中自己做。

编辑:完全归功于j08691 - 对于这个非常简洁的评论:

  

SO过滤您可以使用的代码,它与您在自己的项目中应该使用的内容无关

答案 1 :(得分:0)

The <sup> tag is fine for ordinary paragraph text, but what about text inside a "title" field; for example, ...title="Tombeau de Napoléon 1er"...?

I cannot get the 'er' ('st' in English!) in a superscript position. The <sup> tag has no effect. :-(

相关问题