html文檔頭對css影響
最近開發中,遇到一個問題。body{font-size:12px}對<td></td>內文字不起作用。html文件的完整格式如下
<!--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
-->
<html>
<head>
<title>font size test</title>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description" content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!--
<style type="text/css">
body{
font-size:48px;
/*對td內元素無效,如果無html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
*/
}
</style>
-->
<link rel="stylesheet" href="font.css" type="text/css"/>
</head>
<body>
<p>
p元素內文字
</p>
<hr/>
<table>
<tr>
<td>td內文字</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
-->
<html>
<head>
<title>font size test</title>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description" content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!--
<style type="text/css">
body{
font-size:48px;
/*對td內元素無效,如果無html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
*/
}
</style>
-->
<link rel="stylesheet" href="font.css" type="text/css"/>
</head>
<body>
<p>
p元素內文字
</p>
<hr/>
<table>
<tr>
<td>td內文字</td>
</tr>
</table>
</body>
</html>
允許效果如下

去掉文件頭注釋后
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>font size test</title>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description" content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!--
<style type="text/css">
body{
font-size:48px;
/*對td內元素無效,如果無html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
*/
}
</style>
-->
<link rel="stylesheet" href="font.css" type="text/css"/>
</head>
<body>
<p>
p元素內文字
</p>
<hr/>
<table>
<tr>
<td>td內文字</td>
</tr>
</table>
</body>
</html>
允許效果![]()
不帶文件頭時瀏覽器是怎么解析html文檔的呢?
本文由用戶 chiang 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!