<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Page title - 52css.com</title> </head> <body> <p style="color: red"> ... </p> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page title - 52css.com</title>
<style type="text/css" media="screen">
p { color: red; }
</style>
</head>
<body>... </body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text <title>Page title - 52css.com</title> <link rel="stylesheet" href="name.css" type="text/css" media="screen" /> < /head> <body> ... </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text
<title>Page title - 52css.com</title>
<style type="text/css" media="screen">
@import url("styles.css");
</style>
</head>
<body> ... </body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text <title>Page title - 52css.com</title> <link rel="stylesheet" href="name.css" type="text/css" media="screen" /> </head> <body> ... </body> </html>
低效率的
p{ font-family: arial, helvetica, sans-serif; }
#container { font-family: arial, helvetica, sans-serif; }
#navigation { font-family: arial, helvetica, sans-serif; }
#content { font-family: arial, helvetica, sans-serif; }
#sidebar { font-family: arial, helvetica, sans-serif; }
h1 { font-family: georgia, times, serif; }
高效的
body { font-family: arial, helvetica, sans-serif; }
body { font-family: arial, helvetica, sans-serif; }
h1 { font-family: georgia, times, serif; }
低效率的
h1 { color: #236799; }
h2 { color: #236799; }
h3 { color: #236799; }
h4 { color: #236799; }
高效的h1, h2, h3, h4 { color: #236799; }
低效率的
p { margin: 0 0 1em; }
p { background: #ddd; }
p { color: #666; }
译者注: 对于十六进制颜色值,个人偏向于色值不缩写且英文字母要大写的方式.
高效的
p { margin: 0 0 1em; background: #ddd; color: #666; }
低效率的
body { font-size: 85%; font-family: arial, helvetica, sans-serif; background-image: url(image.gif); background-repeat: no-repeat; background-position: 0 100%; margin-top: 1em; margin-right: 1em; margin-bottom: 0; margin-left: 1em; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-style: solid; border-width: 1px; border-color: red; color: #222222;
高效的
body { font: 85% arial, helvetica, sans-serif; background: url(image.gif) no-repeat 0 100%; margin: 1em 1em 0; padding: 10px; border: 1px solid red; color: #222; }
慎用写法
#news { background: #ddd !important; }
特定情况下可以使用以下方式提高权重级别
#container #news { background: #ddd; }
body #container #news { background: #ddd; }
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛