<pre 属性="属性值">~标签内容~</pre>
属性 | 属性值 | 说明 |
---|---|---|
① width | 长度值(pixel) | 设置单行的显示宽度(文字数),这里的宽度不是按像素计算的,而是按半角英文字符的宽度计算的。此属性仅在Transitioanl DTD和Frameset DTD文档中使用 |
② 通用属性:id、class、title、style、dir、lang、xml:lang |
下面的例子显示了XHTML文件基础结构: 运行打印
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>元素pre</title>
</head>
<body>
<pre>
望洞庭湖赠张丞相 孟浩然
八月湖水平,涵虚混太清。
气蒸云梦泽,波撼岳阳城。
欲济无舟楫,端居耻圣明。
坐观垂钓者,徒有羡鱼情。
</pre>
<pre>
The PRE element tells visual user agents that the enclosed text is "preformatted". When handling preformatted text, visual user agents:
May leave white space intact.
May render text with a fixed-pitch font.
May disable automatic word wrap.
Must not disable bidirectional processing.
Non-visual user agents are not required to respect extra white space in the content of a PRE element.
The DTD fragment above indicates which elements may not appear within a PRE declaration. This is the same as in HTML 3.2, and is intended to preserve constant line spacing and column alignment for text rendered in a fixed pitch font. Authors are discouraged from altering this behavior through style sheets.
</pre>
From<cite> W3C HTML 4.01 Specification</cite>
</body>
</html>