Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

So sánh các phiên bản CSS (CSS1, CSS2, CSS3)

CSS phát triển qua các mức độ (Level) và Module:

Phiên bảnNăm RECĐặc điểm chính
CSS1 12/1996 Font, color, text, margin, padding, border, positioning cơ bản. Model box đơn giản.
CSS2 05/1998 Kế thừa CSS1. Thêm: Media types (print, screen), @font-face, positioning (absolute, fixed), z-index, table layout, generated content (:before/:after), cursor, outline.
CSS2.1 06/2011 Sửa lỗi, làm rõ CSS2. Chuẩn thực tế cho layout nhiều năm (float, clear, inline-block).
CSS3 (Modules) Từ 1999 nay Chia thành **Modules** độc lập: Selectors Level 3, Color Level 3/4, Box Model, Flexbox, Grid, Animations, Transitions, Transforms, Media Queries, Namespaces, Multi-column, Fonts, Backgrounds & Borders...

Khác biệt chính CSS2 vs CSS3 (Modules)

  • Media Queries: Responsive design (CSS3 module).
  • Namespaces: Hỗ trợ XML/SVG namespace trong selector.
  • Selectors Level 3: :nth-child, :not(), ::before/after, attribute selector nâng cao.
  • Color: rgba(), hsl(), opacity, color() function.
  • Layout mới: Flexbox, Grid, Multi-column (không có trong CSS2).
  • Animation/Transition: Động không cần JS.
  • Transform: Xoay, scale, skew, 3D.
  • Web Fonts: @font-face hoàn thiện (WOFF/WOFF2).

CSS hiện nay

Không có "CSS4". Mỗi module version riêng (Selectors Level 4, Color Level 5, Grid Level 2...). Trình duyệt implement từng module. Kiểm tra hỗ trợ tại caniuse.com.