/* All spans with a "lang" attribute are bold */ span[lang] {font-weight:bold;} /* All spans in Vietnamese are green */ span[lang|="vi"] {color:green;} /* All spans in Portuguese are purple */ span[lang="pt"] {color:purple;} /* All spans in US English are blue */ span[lang~="en-us"] {color: blue;} /* Any span in Chinese is red, matches simplified (zh-CN) or traditional (zh-TW) */ span[lang|="zh"] {color: red;} /* All internal links have a gold background */ a[href^="#"] {background-color:gold} /* All links to urls ending in ".cn" are red */ a[href$=".cn"] {color: red;} /* All links to with "example" in the url have a grey background */ a[href*="example"] {background-color: #CCCCCC;}
<p class="hello-example"> <a href="http://example.com">English:</a> <span lang="en-us en-gb en-au en-nz">Hello World!</span> </p> <p class="hello-example"> <a href="#vietnamese">Vietnamese:</a> <span lang="vi-VN">Xin chào!</span> </p> <p class="hello-example"> <a href="#portuguese">Portuguese:</a> <span lang="pt">Olá Mundo!</span> </p> <p class="hello-example"> <a href="http://example.cn">Chinese (Simplified):</a> <span lang="zh-CN">世界您好!</span> </p> <p class="hello-example"> <a href="http://example.cn">Chinese (Traditional):</a> <span lang="zh-TW">世界您好!</span> </p>