html pre标签使用详解

黄舟
黄舟原创
2017-07-08 10:56:382713浏览

html中pre标签怎么用

<html>
<head>
</head>
<body>
12344
</body>
</html>

以上一个网页的源码,那么我现在要把源码输出-
那么用pre标签怎么办?

<pre>
     这里写你想写的代码~~~~
</pre>

就是这样用的

<html>
<head>
</head>
<body>
    12344
<pre>
<html>
<head>
</head>
<body>
    12344
</body>
</html>
</pre>
</body>
</html>

这么写为什么不对?

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

<pre><html><br><head><br></head><br><body><br>    12344<br></body><br></html></pre>

注意 百度修改了代码 & lt; & gt;(没有空格)分别代表< >

用textarea呢?怎么用?

textarea 没问题的

<textarea name="textarea" id="textarea" cols="45" rows="5">
<html>
<head>
</head>
<body>
<code><br>
</textarea>

这次明白了,再加10分吧,多谢了。

<pre></pre>这个标签可以将其包起来的文字排版、格式,原封不动的呈现出来。你输入的东西被原封不动的输出,包括你输入的空格之类的,不用 和<BR>等来表示空格或者回车了.
用于显示源码的确是不错的方案

<pre>
$(
function() {
$("#selectBox").mousemove(
function(event) {
$("span:eq(0)").html($("#selectArea").position().left);
$("span:eq(1)").html(event.offsetX);
if ($("#selectArea").css("position") == "absolute") {
$("#selectArea").css({ left: event.clientX - $("img").offset().left });
$("#selectArea").css({ top: event.clientY - $("img").offset().top });
}
if ($("#selectArea").css("position") == "relative") {
$("#selectArea").css({ left: -(300 - event.offsetX) });
$("#selectArea").css({ top: event.offsetY });
}
}
);
}
);
</per>
<html>
<head>
</head>
<body>
    12344
<pre>
<html>
<head>
</head>
<body>
    12344
</body>
</html>
</pre>
</body>
</html>

这么写为什么不对?

哦,你要在per中写html的代码啊,那你要记得
<>不能直接写成<>,要写出实体形式

< 小于号 < < 
> 大于号 > > 
& 和号 & & 
" 引号 " " 
' 撇号  ' (IE不支持) '

以上就是html pre标签使用详解的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。