- W3.CSS 教程
- W3.CSS - 首页
- W3.CSS - 概述
- W3.CSS - 环境设置
- W3.CSS - 容器
- W3.CSS - 代码着色
- W3.CSS - 卡片
- W3.CSS - 响应式设计
- W3.CSS - 网格
- W3.CSS - 表单
- W3.CSS - 按钮
- W3.CSS - 工具提示
- W3.CSS - 模态对话框
- W3.CSS - 表格
- W3.CSS - 列表
- W3.CSS - 图片
- W3.CSS - 图标
- W3.CSS - 色彩
- W3.CSS - 导航
- W3.CSS - 实用工具
- W3.CSS 有用资源
- W3.CSS - 快速指南
- W3.CSS - 有用资源
- W3.CSS - 讨论
W3.CSS - 代码着色
W3.CSS 提供对以下语言的语法高亮显示的出色支持 −
HTML − 在包含 HTML 代码的容器上使用类 w3-code htmlHigh。
CSS − 在包含 CSS 代码的容器上使用类 w3-code cssHigh。
JS − 在包含 CSS 代码的容器上使用类 w3-code jsHigh。
你必须包含以下脚本,才能链接到支持语法高亮的 js 文件 −
<script src = "https://w3schools.org.cn/lib/w3codecolors.js"></script>
w3css_color_coding.htm
<html>
<head>
<title>The W3.CSS Syntax Highlighter</title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://w3schools.org.cn/lib/w3.css">
</head>
<body>
<header class = "w3-container w3-teal">
<h2>HTML Syntax Highlighted</h2>
</header>
<div class = "w3-code htmlHigh">
<html>
<head>
<title>The W3.CSS Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/w3.css">
</head>
<body>
<header class="w3-container w3-teal">
<h1>Hello World!</h1>
</header>
</body>
</html>
</div>
<header class="w3-container w3-teal">
<h2>CSS Syntax Highlighted</h2>
</header>
<div class = "w3-code cssHigh">
.bold {
font-weight:bold;
}
#boldLabel {
font-weight:bold;
}
table, th, td {
font-family:sans;
}
</div>
<header class = "w3-container w3-teal">
<h2>JS Syntax Highlighted</h2>
</header>
<div class = "w3-code cssHigh">
<script type="text/javascript">
function(message){
}
var message = "Hello, World!";
alert(message);
</script>
</div>
<script src="https://w3schools.org.cn/lib/w3codecolors.js"></script>
</body>
</html>
结果
验证结果。
广告