The < code > Tag###
什么时候用code标签——当你想要把文本特别地显示为代码时
1 .在页面上显示简单的 代码段
<h2>First Example</h2>
<code><h2>First Example</h2>
<p>Some example code that will visually display on the web page</p>
</code>
在浏览器器的显示效果为:
First Example.png
The < pre > Tag###
在pre标签中的文本通常会保留空格和换行符, 而文本也会呈现出等宽字体。
1 . <pre>
保留换行
<h2>SecondExample</h2>
<pre>This is the first line of text.
and this is the second line of text.
I am not using any line break tags;
Because the text is nested in a pre tag,
all "enter" breaks will be formatted literally.
</pre>
所有的 enter 换行,照字面地显示出来,结果如下:
SecondExample.png
2 .
<pre>
保留空白处
<h2>Third Example</h2>
<pre>This example will show how tabbed text
contained in a pre tag will be formatted literally.
</pre>
所有的 空白处,照字面地显示出来,结果如下:
Third Example.png
注意的是,pre标签会导致段落断开,所以例如标题<p>
和 <address>
标签,绝不能包含在<pre>
所定义的块里
* code和pre的嵌套*###
最常用的是在HTML里引用代码: pre套code
<pre>
<code><h2>Third Example</h2>
<p>Some example code that will visually display </p></code>
</pre>
效果:
HTML里引用代码.png
每天都努力一点
谢谢你看完