@web

HTML_pre和code的详解

2016-11-27  本文已影响49人  07120665a058

HTML <pre> 标签定义和用法

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>HTML pre 标签示例</title>
</head>
<body>
<pre>
          All
         I   have
      to          do
         is   learn
           HTML
</pre>
</body>
</html>

HTML <code> 标签定义和用法

<code>
    document.getELementById("id1");
    document.getELementById("id2");
    document.getELementById("id3");
</code>
<br>
document.getELementById("id4");

code标签和pre标签之间的关系

<!DOCTYPE HTML>
<html>
<head>
    <meta charset='utf-8'>
    <title>test</title>
</head>
<body>
<pre>
      <!-- pre中的h1 -->
      <h1>a:hello world hello world</h1>
      <!-- pre中的code -->
      <code>b:hello world hello world</code>
      <!-- pre中 -->
      c:hello world hello world
      <!-- pre中的pre -->
      <pre>d:hello world hello world</pre>
</pre>
<!-- body中 -->
e:hello world hello world
<code>
    <!-- code中 -->
    f:hello world    g:hello world
    <!-- code中的pre -->
    <pre>h:hello world hello world</pre>
</code>
<!-- xmp中 -->
      <xmp>i:<h1>hello world hello world</h1></xmp>
</body>
</html>

显示代码的两种方式:

<pre>
    <code style="background-color: red">hello world</code>
    <code style="background-color:green">hello sdftyworld</code> 
    <code>hello worldsdgh</code>
</pre>
<code>
    <pre style="background-color: red">hello world</pre>
    <pre style="background-color:green">hello sdftyworld</pre>     
    <pre>hello worldsdgh</pre>
</code>

参考文章推荐:
code标签和pre标签
pre和code标签

上一篇 下一篇

猜你喜欢

热点阅读