Heim  >  Artikel  >  Web-Frontend  >  Welche Rolle spielt das HTML-Pre-Tag? Detaillierte Erläuterung der Verwendung von HTML-Pre-Tags und ihrer Attribute

Welche Rolle spielt das HTML-Pre-Tag? Detaillierte Erläuterung der Verwendung von HTML-Pre-Tags und ihrer Attribute

寻∝梦
寻∝梦Original
2018-08-18 17:18:4817156Durchsuche

html pre标签的作用是什么?html pre标签用法及其属性详解你知道吗?那么今天的这篇文章给大家讲解了html pre标签的定义和用法,还有关于html pre标签的作用和使用说明

html pre标签的定义和用法:

pre 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。

e03b848252eb9375d56be284e690e873 标签的一个常见应用就是用来表示计算机的源代码。

可以导致段落断开的标签(例如标题、e388a4556c0f65e1904146cc1a846bee 和 208700f394e4cf40a7aa505373e0130b 标签)绝不能包含在 e03b848252eb9375d56be284e690e873 所定义的块里。尽管有些浏览器会把段落结束标签解释为简单地换行,但是这种行为在所有浏览器上并不都是一样的。

pre 元素中允许的文本可以包括物理样式和基于内容的样式变化,还有链接、图像和水平分隔线。当把其他标签(比如 3499910bf9dac5ae3c52d5ede7383485 标签)放到 e03b848252eb9375d56be284e690e873 块中时,就像放在 HTML/XHTML 文档的其他部分中一样即可。请看下面的例子:

<pre class="brush:php;toolbar:false">
&lt;html&gt;
&lt;head&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;loadxmldoc.js&quot;&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
    xmlDoc=<a href="dom_loadxmldoc.asp">loadXMLDoc</a>(&quot;books.xml&quot;);
    document.write(&quot;xmlDoc is loaded, ready for use&quot;);
  &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

在上面的代码中,e03b848252eb9375d56be284e690e873 标签中的特殊符号被转换为符号实体,比如 "<" 代表 "7d580d702c39244e93a07ae109a93e60"。另外,请注意蓝色的代码,我们在 e03b848252eb9375d56be284e690e873 标签中使用了链接,也就是 3499910bf9dac5ae3c52d5ede7383485 标签。上面这段代码的显示效果如下:

<html>
<head>
  <script type="text/javascript" src="loadxmldoc.js">
</script>
</head>
<body>
  <script type="text/javascript">
    xmlDoc=loadXMLDoc("books.xml");
    document.write("xmlDoc is loaded, ready for use");
  </script>
</body>
</html>

html pre标签可选的属性:

width :  number  :  定义每行的最大字符数(通常是 40、80 或 132)。

htmle03b848252eb9375d56be284e690e873标签的作用及使用说明:

1、该标签可定义预格式化的文本,被包围在 pre 元素中的文本通常会保留空格和换行符,并且文本会呈现为等宽字体。该标签的一个常见应用就是用来表示计算机的源代码。

2、该元素中允许的文本可以包括物理样式和基于内容的样式变化,还有链接、图像和水平分隔线。当把其他标签(比如 3499910bf9dac5ae3c52d5ede7383485 标签)放到 e03b848252eb9375d56be284e690e873 块中时,就像放在 HTML/XHTML 文档的其他部分中一样即可。

3、标签中的特殊符号被转换为符号实体,比如 "<" 代表 "7d580d702c39244e93a07ae109a93e60"。

4、可以导致段落断开的标签(比如4a249f0d628e2318394fd9b75b4636b1、e388a4556c0f65e1904146cc1a846bee 和 208700f394e4cf40a7aa505373e0130b 标签)尽量不要包含在 e03b848252eb9375d56be284e690e873 所定义的块里,我试过现在的浏览器(Google、IE和火狐),虽然可以把段落结束标签解释为简单地换行,但是在代码编辑器里会报错 "Invalid location of tag (h1)."

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
   <pre class="brush:php;toolbar:false">你好     我是Natalie
    我即将成为<h1>一名技术</h1>人员。

HTML 与 XHTML 之间的差异

在 HTML 4.01 中,pre 元素的 "width" 属性是不被赞成使用的。

在 XHTML 1.0 Strict DTD 中,pre 元素的 "width" 属性是不被支持的。

提示和注释:

提示:制表符(tab)在 e03b848252eb9375d56be284e690e873 标签定义的块当中可以起到应有的作用,每个制表符占据 8 个字符的位置。但是我们不推荐使用它,因为在不同的浏览器中,Tab 的实现各不相同。在用 e03b848252eb9375d56be284e690e873 标签格式化的文档段中使用空格,可以确保文本正确的水平位置。

提示:如果您希望使用 e03b848252eb9375d56be284e690e873 标签来定义计算机源代码,比如 HTML 源代码,请使用符号实体来表示特殊字符,比如 "<" 代表 "7d580d702c39244e93a07ae109a93e60","&" 代表 "&"。

提示:在 W3School 中,非常多页面中的源代码实例都是通过 e03b848252eb9375d56be284e690e873 标签定义的,您可以参考这些页面,学习如何使用该标签。我们甚至把 e03b848252eb9375d56be284e690e873 标签与 ffbe95d20f3893062224282accb13e8f 标签结合起来使用,以获得更加精确的语义。

【相关推荐】

html5 border属性怎么设置?html5 table中的border属性介绍

HTML ins标签常用的用法有哪些?HTML ins常用属性的介绍



Das obige ist der detaillierte Inhalt vonWelche Rolle spielt das HTML-Pre-Tag? Detaillierte Erläuterung der Verwendung von HTML-Pre-Tags und ihrer Attribute. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn