这是符合标准的结果吗?

问题描述:

这里是我的代码:这是符合标准的结果吗?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:acid="http://acid/"> 

<head> 

    <title>Acid4 Test</title> 

    <link rel="stylesheet" type="text/css" href="acid4.css" /> 

</head> 

<body> 

<h1><acid:textGradient></acid:textGradient>Acid<span>4</span></h1> 

</body> 

</html> 

和样式表:

@font-face { 
    src: url('syncopateBold.ttf'); 
    font-family: Syncopate; 
    font-weight: bold; 
    font-style: normal; 
    font-variant: none; 
} 

@font-face { 
    src: url('syncopate.ttf'); 
    font-family: Syncopate; 
    font-weight: normal; 
    font-style: normal; 
    font-variant: none; 
} 

* { 
    margin: 0; 
    padding: 0; 
} 

body > *:first-child { /* our title */ 
    font-family: Syncopate; 
    font-size: 4em; 
    font-weight: bold; 
    margin: 0; 
    text-shadow: 0 0 10px black; 
    text-transform: lowercase; 

    *color: blue; 
    _color: red; 
} 

body > *:first-child > span { /* The 4 in Acid4 */ 
    color: white; 
    font-weight: normal; 
    font-size: 200%; 
    vertical-align: sub; 
    z-index: 999; 
} 

acid\:textGradient:empty { 
    background: url('textGradient.png') repeat-x; 
    display: block; 
    height: 31px; 
    margin-top: 50px; 
    position: absolute; 
    width: 210px; 
} 

。下面是结果我收到了谷歌浏览器:

Acid4 test result on Google Chrome

这是我的期望。然而,火狐和IE9显示此:

Acid4 test result on Firefox and Internet Explorer 9

我想知道,哪一个是符合标准的结果呢?

字体可以在这里找到:http://www.google.com/webfonts/family?family=Syncopate&subset=latin和textGradient.png只是一个渐变图像。

+0

快速提示:您可以从'*:first-child'中删除'*',这是多余的。 – BoltClock 2011-06-06 01:27:46

尽管人为设计的例子(所有“酸”的东西都是完全不相关的),但这实际上是一个关于垂直对齐的问题,尤其是vertical-align:sub。据我所知,css2.1和css3都没有定义vertical-align:sub应该移动多少文本。他们只是说

下框的基线到合适的位置的 父盒标。 (该值对 元素文本的字体尺寸没有 效果。)

所以没有标准,Chrome已经只是选择了不同的值,以Firefox浏览器。

我建议使用类似vertical-align: -10%;的东西代替。

我敢肯定,acid:xmlns应该是xmlns:acid

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:acid="http://acid/"> 
<head> 
    <title>Acid4 Test</title> 
    <link rel="stylesheet" type="text/css" href="acid4.css" /> 
</head> 
<body> 
<h1><acid:textGradient></acid:textGradient>Acid<span>4</span></h1> 
</body> 
</html> 

当然,我假设xmlns:acid实际上不是"http://acid/",因为这涉及到用户的本地 localhost上。

+0

......这并不重要,是吗?无论如何修复。 – Ryan 2011-06-05 22:30:04

+0

@minitech:它从有效性的角度出发。你只是不要用'[ns]:xmlns'声明XML命名空间属性,你可以这样做:'xmlns:[ns]' – BoltClock 2011-06-05 22:35:09

+0

@minitech是'xmlns:acid'的实际值'http:// acid /'' ,或者你只是用占位符替换实际值? – mc10 2011-06-05 22:36:59