HTML 设置→ 字号: 颜色: 背景色: 默认
HTML参考 > HTML元素
整体构造元素文字元素样式与配置元素列表元素链接元素表单元素表格元素图片与对象元素框架元素注音标注元素其它元素
> 文字元素
abbracronymemstrongdfnkbdsampcodevarciteblockquoteqsupsubpbrinsdelpreplaintextxmp
> code
code
适用DTD:Strict Transitional Frameset   适用浏览器:All
释义
计算机代码片段(computer code)

语法
<code 属性="属性值">~标签内容~</code>

说明
code元素用来在HTML文档中输出一段程序设计中的计算机代码。终止标签不可省略显示
在一般浏览器中,code元素的显示效果是将标签内容以等宽文字来显示

属性
属性 属性值 说明
① 通用属性:id、class、title、style、dir、lang、xml:lang 查看
注:W3C非推荐属性或非标准属性 仅XHTML适用 默认值

示范
<code>代码块</code>

范例
下面的例子显示了XHTML文件基础结构: 运行打印
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>元素code</title>
</head>
<body>
<p>
...
<script type="text/javascript">
var str = "This is a string.";
pos = str.indexOf("is");
alert(pos);
</script>
...
<code>var str = "This is a string.";
pos = str.indexOf("is");
alert(pos);
</code>
</p>
</body>
</html>

参阅
kbd
samp
var



© 2008 liuming lium03@tom.com
395310500
, All Rights Reserved.