HTML格式


如果使用文字处理程序,则必须熟悉使文本变为粗体,斜体或带下划线的功能;这些只是表示文本如何在HTML和XHTML中显示的十个选项中的三个。

粗体


任何出现在其中的东西 ... 元素,以粗体显示,如下所示:


<!DOCTYPE html>
<html>

    <head>
        <title>Bold Text Example</title>
    </head>
	
    <body>
        <p>The following word uses a <b>bold</b> typeface.</p>
    </body>
	
</html>


这将产生以下结果:

斜体文字


任何出现在其中的东西 ... 元素以斜体显示,如下所示:

<!DOCTYPE html>
<html>

    <head>
        <title>Italic Text Example</title>
    </head>
	
    <body>
        <p>The following word uses an <i>italicized</i> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

带下划线的文字


任何出现在其中的东西 ... 元素,带有下划线显示,如下所示:

<!DOCTYPE html>
<html>

    <head>
        <title>Underlined Text Example</title>
    </head>
	
    <body>
        <p>The following word uses an <u>underlined</u> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

罢工文字


任何出现在其中的东西 ... 元素显示为删除线,该删除线是穿过文本的细线,如下所示:

<!DOCTYPE html>
<html>

    <head>
        <title>Strike Text Example</title>
    </head>
	
    <body>
        <p>The following word uses a <strike>strikethrough</strike> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

等宽字体


一个的内容 ... 元素以等宽字体书写。大多数字体都称为可变宽度字体,因为不同的字母具有不同的宽度(例如,字母“ m”比字母“ i”宽)。但是,在等宽字体中,每个字母具有相同的宽度。

<!DOCTYPE html>
<html>

    <head>
        <title>Monospaced Font Example</title>
    </head>
	
    <body>
        <p>The following word uses a <tt>monospaced</tt> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

上标文字


一个的内容 ... 元素标有上标;所使用的字体大小与其周围的字符相同,但是显示为比其他字符高半个字符的高度。

<!DOCTYPE html>
<html>

    <head>
        <title>Superscript Text Example</title>
    </head>
	
    <body>
        <p>The following word uses a <sup>superscript</sup> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

下标文字


一个的内容 ... 元素写在下标上;所使用的字体大小与周围的字符相同,但显示为在其他字符下方半个字符的高度。

<!DOCTYPE html>
<html>

    <head>
        <title>Subscript Text Example</title>
    </head>
	
    <body>
        <p>The following word uses a <sub>subscript</sub> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

插入文字


任何出现在其中的东西...元素显示为插入的文本。

<!DOCTYPE html>
<html>

    <head>
        <title>Inserted Text Example</title>
    </head>
	
    <body>
        <p>I want to drink <del>cola</del> <ins>wine</ins></p>
    </body>
	
</html>

这将产生以下结果:

删除文字


任何出现在其中的东西... 元素显示为已删除的文本。

<!DOCTYPE html>
<html>

    <head>
        <title>Deleted Text Example</title>
    </head>
	
    <body>
        <p>I want to drink <del>cola</del> <ins>wine</ins></p>
    </body>
	
</html>

这将产生以下结果:

较大的文字


的内容 ... 元素显示的字体大小比周围其他文本大一号,如下所示:

<!DOCTYPE html>
<html>

    <head>
        <title>Larger Text Example</title>
    </head>
	
    <body>
        <p>The following word uses a <big>big</big> typeface.</p>
    </body>
	
</html>

这将产生以下结果:

较小的文字


的内容 ... 元素显示的字体大小比周围的其余文本小一种,如下所示:

<!DOCTYPE html>
<html>

    <head>
        <title>Smaller Text Example</title>
    </head>

    <body>
        <p>The following word uses a <small>small</small> typeface.</p>
    </body>

</html>

这将产生以下结果:

分组内容


Theand元素允许你将几个元素组合在一起以创建页面的节或子节。

例如,你可能希望将所有脚注放在

元素内的页面上,以指示该

元素内的所有元素都与脚注相关。然后,你可以将样式附加到此

元素,以便使用一组特殊的样式规则显示它们。

<!DOCTYPE html>
<html>

    <head>
        <title>Div Tag Example</title>
    </head>
	
    <body>
        <div id = "menu" align = "middle" >
            <a href = "/index.htm">HOME</a> |
            <a href = "/about/contact_us.htm">CONTACT</a> |
            <a href = "/about/index.htm">ABOUT</a>
        </div>

        <div id = "content" align = "left" >
            <h5>Content Articles</h5>
            <p>Actual content goes here.....</p>
        </div>
    </body>
	
</html>

这将产生以下结果:

另一方面,元素只能用于对内联元素进行分组。因此,如果你希望将句子或段落的一部分归为一组,则可以使用元素,如下所示。

<!DOCTYPE html>
<html>

    <head>
        <title>Span Tag Example</title>
    </head>
	
    <body>
        <p>This is the example of <span style = "color:green">span tag</span>
            and the <span style = "color:red">div tag</span> alongwith CSS</p>
    </body>
	
</html>

这将产生以下结果:

这些标记通常与CSS一起使用,以允许你将样式附加到页面的一部分。