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
每天都努力一點
謝謝你看完