<h1 class="version-one">red headine</h1> <h1 class="version-two">blue heading</h1> <style> .version-one { /* your styles for the class version-one */ font-size: 3em; color: red; } .version-two { /* your styles for the class version-two */ font-size: 3em; color: blue; } </style>
You also could use h1.version-one as the selector to ensure you’re only targetting h1-elements with this class and not other elements with this class (e.g. a paragraph).
หรือ
<style> .version-one h1 { color: red; } .version-one h2 { color: orange; } .version-two h1 { color: blue; } .version-two h2 { color: purple; } </style> <div class="version-one"> <h1>lorem lipsum</h1> <h2>lorem lipsum</h2> </div> <div class="version-two"> <h1>lorem lipsum</h1> <h2>lorem lipsum</h2> </div>
http://jsfiddle.net/LDNjg/