W3C与 CSS:模块等级、历史版本和设备Profile
保留全部模块与Profile条目,纠正CSS2日期和统一CSS4说法。
学完这一章,你能够
- 保留全部模块与Profile条目,纠正CSS2日期和统一CSS4说法。
- 保留全部模块与Profile条目,纠正CSS2日期和统一CSS4说法。
CSS1、CSS2和2.1
CSS用于表现和布局,CSS1于1996年成为推荐,并有后续修订;CSS2初版1998-05-12,不是正文误写的1999-01-11。CSS2.1与DOM Level2 Style、style属性规范各有自己的版本和日期。
模块而非统一大版本
Namespaces、Selectors、UI、Fonts、Color、Backgrounds/Borders、Text、Lists/Counters、Line/Inline、Box、Multi-column、Ruby、Speech、Paged Media、Generated Content for Paged Media、Values/Units、Cascade、Template Layout和Media Queries全部保留。
模块独立编号和演进,不存在所有功能一齐完成的单一“CSS4”。Selectors Level4与Colour Level4等不同模块不能混为同一个总版本;旧模块更名/拆分要明确说明。
媒体和Profile的历史边界
Mobile、TV、Print Profile代表特定时期面向设备的约束集合,不是三种CSS属性类型。现代响应式/打印和可访问性需按实际媒体查询及模块实现,不用这些旧Profile代替所有设备适配。
本章用自己的元素分别验证cascade、继承、选择器及布局条件;历史规范表不等于浏览器对每个历史模块均实现。
历史规范逐项时间线(日期和阶段对应指定历史版本)
| 规范条目 | 官方版本名 | 日期 | 当时阶段 | 指定版本地址 |
| CSS 1 | Cascading Style Sheets, level 1 | 1996-12-17 | Recommendation | https://www.w3.org/TR/REC-CSS1-961217 |
| CSS 1 (Revised) | Cascading Style Sheets (CSS1) Level 1 Specification | 2008-04-11 | Recommendation | https://www.w3.org/TR/2008/REC-CSS1-20080411/ |
| CSS 2 | Cascading Style Sheets, level 2 (CSS2) Specification | 1998-05-12 | Recommendation | https://www.w3.org/TR/1998/REC-CSS2-19980512/ |
| CSS 2.1 | Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification | 2011-06-07 | Recommendation | https://www.w3.org/TR/2011/REC-CSS2-20110607/ |
| DOM Level 2 Style Specification | Document Object Model (DOM) Level 2 Style Specification | 2000-11-13 | Recommendation | https://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/ |
| CSS Style Attributes | CSS Style Attributes | 2010-10-12 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2010/CR-css-style-attr-20101012/ |
| CSS 3 Namespaces Module | CSS Namespaces Module | 2011-09-29 | Recommendation | https://www.w3.org/TR/2011/REC-css3-namespace-20110929/ |
| CSS 3 Selectors | Selectors Level 3 | 2011-09-29 | Recommendation | https://www.w3.org/TR/2011/REC-css3-selectors-20110929/ |
| CSS 3 User Interface Module | CSS Basic User Interface Module Level 3 (CSS3 UI) | 2012-01-17 | Last Call Working Draft | https://www.w3.org/TR/2012/WD-css3-ui-20120117/ |
| CSS 3 Fonts Module | CSS Fonts Module Level 3 | 2013-02-12 | Working Draft | https://www.w3.org/TR/2013/WD-css3-fonts-20130212/ |
| CSS 3 Color Module | CSS Color Module Level 3 | 2011-06-07 | Recommendation | https://www.w3.org/TR/2011/REC-css3-color-20110607/ |
| CSS 3 Backgrounds and Borders Module | CSS Backgrounds and Borders Module Level 3 | 2012-07-24 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2012/CR-css3-background-20120724/ |
| CSS 3 Text Module | CSS Text Module Level 3 | 2012-11-13 | Working Draft | https://www.w3.org/TR/2012/WD-css3-text-20121113/ |
| CSS 3 Lists and Counters Module | CSS Lists and Counters Module Level 3 | 2011-05-24 | Working Draft | https://www.w3.org/TR/2011/WD-css3-lists-20110524 |
| CSS 3 Line Module | CSS3 module: line | 2002-05-15 | Working Draft | https://www.w3.org/TR/2002/WD-css3-linebox-20020515/ |
| CSS 3 Basic Box model | CSS basic box model | 2007-08-09 | Working Draft | https://www.w3.org/TR/2007/WD-css3-box-20070809/ |
| CSS 3 Multi-column Layout Module | CSS Multi-column Layout Module | 2011-04-12 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2011/CR-css3-multicol-20110412/ |
| CSS 3 Ruby Module | CSS3 Ruby Module | 2011-06-30 | Working Draft | https://www.w3.org/TR/2011/WD-css3-ruby-20110630/ |
| CSS 3 Speech Module | CSS Speech Module | 2012-03-20 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2012/CR-css3-speech-20120320/ |
| CSS 3 Paged Media Module | CSS3 Module: Paged Media | 2006-10-10 | Last Call Working Draft | https://www.w3.org/TR/2006/WD-css3-page-20061010/ |
| CSS 3 Generated content for Paged Media Module | CSS Generated Content for Paged Media Module | 2011-11-29 | Working Draft | https://www.w3.org/TR/2011/WD-css3-gcpm-20111129/ |
| CSS 3 Values and Units Module | CSS Values and Units Module Level 3 | 2012-08-28 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2012/CR-css3-values-20120828/ |
| CSS 3 Cascading and Inheritance | CSS Cascading and Inheritance Level 3 | 2013-01-03 | Working Draft | https://www.w3.org/TR/2013/WD-css3-cascade-20130103/ |
| CSS 3 Template Layout Module | CSS Template Layout Module | 2011-11-29 | Working Draft | https://www.w3.org/TR/2011/WD-css3-layout-20111129/ |
| CSS 3 Media Queries | Media Queries | 2012-06-19 | Recommendation | https://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/ |
| CSS Mobile Profile 2.0 | CSS Mobile Profile 2.0 | 2008-12-10 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2008/CR-css-mobile-20081210 |
| CSS TV Profile 1.0 | CSS TV Profile 1.0 | 2003-05-14 | Candidate Recommendation Snapshot | https://www.w3.org/TR/2003/CR-css-tv-20030514 |
| CSS Print Profile 1.0 | CSS Print Profile | 2006-10-13 | Last Call Working Draft | https://www.w3.org/TR/2006/WD-css-print-20061013/ |
概念、用途与有效条件
| 术语/形式 | 含义及用途 | 边界 |
| 模块与Profiles | 技术范围与选择集合 | 不存在统一一整版CSS4的工程保证 |
| @layer | 命名层顺序参与层叠 | 例子同源普通声明,不概括!important逆序 |
| 继承 | 某些属性向子元素传递 | 并非全部属性继承 |
| Grid/gap | 真实双列与轨道间距 | 本例容器440px,16→24→16 |
| 规范日期 | 特定文档历史 | 不自动说明当前浏览器支持 |
本章独立核心源码与验证步骤
展开查看收起
css
@layer base,learning;
@layer base { #demo .card { color:rgb(220,38,38);font-size:18px;padding:16px;border:2px solid currentColor } }
@layer learning { #demo .card[data-state="ready"] { color:rgb(37,99,235) } }
#grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;width:440px;max-width:100%;margin:20px 0}
#grid.wider{gap:24px}
尝试一下 ↗ 在独立页面修改并运行
- 真实层叠/继承颜色rgb(37,99,235),双列初始212px;按钮间距16→24→16。
本章附件与实例包
课程关联工程包(登记关联16章) · 含当前章节或实例 · mbskycom202611a441.zip
常见错误与边界检查
- 将历史文档日期/阶段当作现行状态,或把REC所有段落误当规范性要求。
- 用元数据/解析/局部运行代替整份规范语义验收及完整互操作性。
技术规范与官方资料
练习与参考解答
查看参考解答
对照指定版本、处理器、命名空间及失败条件,保持运行输入/输出/源码校验值对应。