HTML |下标和上标标记

下标: 标记用于向HTML文档添加下标文本。 标记定义下标文本。下标文本显示在标准线下半个字符,有时以较小的字体呈现。下标文本可用于化学公式,如H2O可写成H 2. O。 上标: 标记用于向HTML文档添加上标文本。 标记定义上标文本。上标文本显示在标准线上方半个字符,有时以较小的字体呈现。上标文本可用于脚注。 例如:

null
  1. HTML代码中的超级脚本和子脚本:

html

<!DOCTYPE html>
< html >
< body >
< p >Testing < sub >subscript text</ sub ></ p >
< p >Testing < sup >superscript text</ sup ></ p >
</ body >
</ html >


  1. 输出:

图片[1]-HTML |下标和上标标记-yiteyi-C++库

  1. 使用CSS设置下标样式:

html

<!DOCTYPE html>
< html >
< head >
< style >
sub {
vertical-align: sub;
font-size: small;
}
</ style >
</ head >
< body >
< p >A sub element is displayed like this</ p >
< p >This text contains < sub >subscript text</ sub ></ p >
< p >Change the default CSS settings to see the effect.</ p >
</ body >
</ html >


  1. 输出:

图片[2]-HTML |下标和上标标记-yiteyi-C++库

  1. CSS的另一个例子:

html

<!DOCTYPE html>
< html >
< head >
< style >
sub {
vertical-align: sub;
font-size: medium;
}
</ style >
</ head >
< body >
< p >Examples to demonstrate subscript text</ p >
< p > Chemical formula of water is H< sub >2</ sub >O</ p >
< p >T< sub >i+2</ sub >= T< sub >i</ sub > + T< sub >i+1</ sub ></ p >
< p >Change the default CSS settings to see the effect.</ p >
</ body >
</ html >


  1. 输出:

图片[3]-HTML |下标和上标标记-yiteyi-C++库

  1. 带有CSS的上标示例:

html

<!DOCTYPE html>
< html >
< head >
< style >
sup {
vertical-align: super;
font-size: small;
}
</ style >
</ head >
< body >
< p >A sup element is displayed like this:</ p >
< p >This text contains < sup >superscript text</ sup ></ p >
< p >Change the default CSS settings to see the effect.</ p >
</ body >
</ html >


  1. 输出:

图片[4]-HTML |下标和上标标记-yiteyi-C++库

  1. 使用super和 下标 :

html

<!DOCTYPE html>
< html >
< head >
< style >
sup {
vertical-align: super;
font-size: medium;
}
</ style >
</ head >
< body >
< p >Examples to demonstrate superscript text</ p >
< p >2 < sup >4</ sup >=16</ p >
< p >X < sup >4</ sup >+ Y< sup >6</ sup ></ p >
< p >9< sup >th</ sup > of september</ p >
< p >Change the default CSS settings to see the effect.</ p >
</ body >
</ html >


  1. 输出:

图片[5]-HTML |下标和上标标记-yiteyi-C++库

支持的浏览器: 下面列出了支持的浏览器。

  • 谷歌浏览器
  • Internet Explorer
  • 火狐
  • 歌剧
  • 游猎

本文由 Shubrodeep Banerjee .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 写极客。组织 或者把你的文章寄去评论-team@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。 如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。

HTML是网页的基础,通过构建网站和Web应用程序来进行网页开发。通过以下步骤,您可以从头开始学习HTML HTML教程 HTML示例 .

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享