Web 前端开发小测验, Part 1 之 CSS
这是 @devqin 在 NADbb 上发的一个找虐的测试. (原作者有个提示: Warning: might hurt your feelings).
我来挨个找证据, 今天是 part 1, CSS 部分.
1)
1 2 3 |
|
Are CSS property names case-sensitive?
CSS 属性名是大小写敏感的吗 ?
答: 不敏感. Cascading Style Sheets, level 1 的 7.1 Forward-compatible parsing 最后有这么一段话,
All CSS style sheets are case-insensitive, except for parts that are not under the control of CSS. I.e., in CSS1, font family names and URLs can be case-sensitive. Also, the case-sensitivity of the CLASS and ID attributes is under the control of HTML.
因此, 只有不受 CSS 控制的, 如 font family
的名字, url
, 以及受 HTML
控制的 ID
和 class
大小写敏感, 其他受 CSS 控制的内容都是大小写不敏感的.
2) Does setting margin-top
and margin-bottom
have an affect on an inline element ?
margin-top
与 margin-bottom
对内联元素是否有效 ?
答: 没效果, Cascading Style Sheets, level 1 的 4.2 Inline elements 中有如下描述:
If the inline element has margins, borders, padding or text decorations attached, these will have no effect where the element is broken.
CSS2.1 中, 8.3 Margin properties: ‘margin-top’, ‘margin-right’, ‘margin-bottom’, ‘margin-left’, and ‘margin’ 节关于 margin-top
和 margin-bottom
有如下描述:
These properties have no effect on non-replaced inline elements.
关于 non-replaced 与 replaced element 的定义可以参考 CSS2.1 中的 Replaced element