使用CSS3内置计数器功能,实现自动编号;
body {
counter-reset: section;
}
h1 {
counter-reset: subsection;
}
h1:before {
content: "Section " counter(section) ". ";
counter-increment: section;
}
h2:before {
counter-increment: subsection;
content: counter(section) "." counter(subsection) " ";
}
<p><b>注释:</b>如果已规定 !DOCTYPE,那么 Internet Explorer 8 (以及更高版本)支持 counter-increment 属性。</p>
<h1>HTML tutorials</h1>
<h2>HTML Tutorial</h2>
<h2>XHTML Tutorial</h2>
<h2>CSS Tutorial</h2>
<h1>Scripting tutorials</h1>
<h2>JavaScript</h2>
<h2>VBScript</h2>
<h1>XML tutorials</h1>
<h2>XML</h2>
<h2>XSL</h2>


