|
1 | | -# Effective CSS Reset – Requirements v1 (EN) |
| 1 | +# Effective CSS – Design Principles |
2 | 2 |
|
3 | | -## 0. Meta |
| 3 | +This document describes the high-level design decisions and philosophy. |
| 4 | +For implementation details, see the inline comments in the CSS source files. |
4 | 5 |
|
5 | | -- **META-001**: `id = "effective-css-reset"` |
6 | | -- **META-002**: `version = "0.1.0"` |
7 | | -- **META-003**: `status = "draft"` |
8 | | -- **META-004**: `target-browsers = "Evergreen (Chrome, Edge, Firefox, Safari, last 2–3 years)"` |
9 | | -- **META-005**: No legacy support for IE / old Android stock browsers. |
| 6 | +## Target Browsers |
10 | 7 |
|
11 | | ---- |
| 8 | +**Evergreen browsers only:** Chrome, Edge, Firefox, Safari (last 2-3 years). |
| 9 | +No legacy support for IE or old Android stock browsers. |
12 | 10 |
|
13 | | -## 1. Layer architecture |
| 11 | +## Layer Architecture |
14 | 12 |
|
15 | | -- **LAY-001**: The implementation MUST use `@layer` for structure. |
16 | | -- **LAY-002**: Reserved layer names: |
17 | | - - `reset` |
18 | | - - `fixes` |
19 | | - - `elements` |
20 | | -- **LAY-003**: Each file MUST declare its own layer via `@layer <name> { ... }` at top level. |
21 | | -- **LAY-004**: Recommended declaration order in global CSS: |
| 13 | +```css |
| 14 | +@layer reset, fixes, elements; |
| 15 | +``` |
22 | 16 |
|
23 | | - ```css |
24 | | - @layer reset, fixes, elements; |
25 | | -```` |
| 17 | +| Layer | Purpose | Required | |
| 18 | +|-------|---------|----------| |
| 19 | +| `reset` | Normalize UA defaults across browsers | Yes | |
| 20 | +| `fixes` | Browser-specific workarounds and bug fixes | Yes | |
| 21 | +| `elements` | Sensible defaults for HTML elements | Optional | |
26 | 22 |
|
27 | | -* **LAY-005**: Global utility classes (e.g. `.sr-only`, `.stack`, `.btn`) MUST NOT be defined. |
28 | | -* **LAY-006**: Global naming schemes (e.g. `.u-*`, `.c-*`, `.o-*`) MUST NOT be defined in this project. |
| 23 | +The cascade order ensures: `reset < fixes < elements < your styles` |
29 | 24 |
|
30 | | ---- |
| 25 | +Using `@layer` means your styles always win over these defaults, regardless of specificity. |
31 | 26 |
|
32 | | -## 2. Layer `reset` |
| 27 | +## Design Decisions |
33 | 28 |
|
34 | | -### 2.1 General |
| 29 | +### What We Reset |
35 | 30 |
|
36 | | -* **RST-001**: Layer name MUST be `reset`. |
37 | | -* **RST-002**: Goal: normalize UA defaults across browsers, without browser-specific bug fixes. |
38 | | -* **RST-003**: The reset MUST apply to all standardized HTML elements (including `::before` / `::after`), not only `body`. |
| 31 | +- **Box model:** `border-box` on all elements (directly, not via inheritance) |
| 32 | +- **Spacing:** Zero margins and padding on all elements |
| 33 | +- **Media:** Block display and responsive sizing for images, video, etc. |
| 34 | +- **Forms:** Inherit font and color from parent |
| 35 | +- **Tables:** Collapsed borders, inherited colors |
39 | 36 |
|
40 | | -### 2.2 Margin / padding |
| 37 | +### What We Fix |
41 | 38 |
|
42 | | -* **RST-010**: All HTML elements MUST get `margin: 0;`. |
43 | | -* **RST-011**: All HTML elements MUST get `padding: 0;`. |
44 | | -* **RST-012**: Any exceptions to RST-010/011 (if introduced) MUST be explicitly documented in comments. |
| 39 | +- **Text inflation:** Prevent mobile browsers from enlarging text |
| 40 | +- **Reduced motion:** Respect user preference, disable animations |
| 41 | +- **Hidden attribute:** Ensure `[hidden]` always works |
| 42 | +- **Color scheme:** Support automatic light/dark mode |
45 | 43 |
|
46 | | -### 2.3 Box sizing |
| 44 | +### What We Enhance (Optional) |
47 | 45 |
|
48 | | -* **RST-020**: The global box model MUST be `box-sizing: border-box;`. |
| 46 | +- **Typography:** System font stacks, balanced headings, prettier paragraphs |
| 47 | +- **Links:** Inherit color, improved underlines |
| 48 | +- **Scroll behavior:** Margin for anchor links |
| 49 | +- **Modern CSS:** `interpolate-size` for height animations, `hanging-punctuation` |
49 | 50 |
|
50 | | -* **RST-021**: The pattern |
| 51 | +### What We Don't Touch |
51 | 52 |
|
52 | | - ```css |
53 | | - html { |
54 | | - box-sizing: border-box; |
55 | | - } |
56 | | - *, |
57 | | - *::before, |
58 | | - *::after { |
59 | | - box-sizing: inherit; |
60 | | - } |
61 | | - ``` |
| 53 | +- **Focus indicators:** Never removed (accessibility) |
| 54 | +- **Cursor styles:** No global `cursor: pointer` (accessibility) |
| 55 | +- **List styles:** Preserved on `ul`/`ol` (semantic defaults) |
| 56 | +- **Heading sizes:** No type scale (use your own) |
62 | 57 |
|
63 | | - MUST NOT be used, due to issues with Web Components and slotted content. |
| 58 | +## Web Components Compatibility |
64 | 59 |
|
65 | | -* **RST-022**: `box-sizing` MUST be set directly on the elements (or HTML tag list), not via inheritance. |
| 60 | +- Uses direct `box-sizing` instead of inheritance pattern |
| 61 | +- Does not style inside Shadow DOM |
| 62 | +- Does not break Custom Elements or unknown tags |
66 | 63 |
|
67 | | -* **RST-023**: The “inheriting box-sizing from html” pattern is considered **deprecated** for this project. |
| 64 | +## Non-Goals |
68 | 65 |
|
69 | | -*(Exact selector strategy – e.g. full HTML tag list vs. `html *` – is implementation detail, but MUST respect WC requirements in §5.)* |
| 66 | +This project intentionally does NOT provide: |
70 | 67 |
|
71 | | -### 2.4 Display & media elements |
| 68 | +- Utility classes (`.sr-only`, `.stack`, `.container`) |
| 69 | +- UI components (buttons, cards, modals) |
| 70 | +- Naming conventions (`.u-*`, `.c-*`, BEM) |
| 71 | +- Fluid typography or type scales |
| 72 | +- Build tool configurations |
| 73 | +- Preprocessor features (SCSS, PostCSS) |
72 | 74 |
|
73 | | -* **RST-030**: `html` and `body` MUST keep their UA default display types (no forced display overrides). |
74 | | -* **RST-031**: For `img`, `picture`, `video`, `canvas`, `svg` the following MUST be applied: |
| 75 | +## References |
75 | 76 |
|
76 | | - ```css |
77 | | - @layer reset { |
78 | | - img, |
79 | | - picture, |
80 | | - video, |
81 | | - canvas, |
82 | | - svg { |
83 | | - display: block; |
84 | | - max-inline-size: 100%; |
85 | | - block-size: auto; |
86 | | - } |
87 | | - } |
88 | | - ``` |
89 | | - |
90 | | -### 2.5 Forms & interactive elements |
91 | | - |
92 | | -* **RST-040**: `button`, `input`, `textarea`, `select` MUST use `font: inherit;`. |
93 | | -* **RST-041**: Focus indicators MUST NOT be removed in `reset` (no global `outline: none;`). |
94 | | -* **RST-042**: `cursor: pointer;` MUST NOT be set globally in `reset` (only local, if ever, in higher layers). |
95 | | - |
96 | | ---- |
97 | | - |
98 | | -## 3. Layer `fixes` |
99 | | - |
100 | | -### 3.1 General |
101 | | - |
102 | | -* **UFX-001**: Layer name MUST be `fixes`. |
103 | | -* **UFX-002**: Goal: browser-specific workarounds / bug fixes; no visual design decisions. |
104 | | -* **UFX-003**: Every fix MUST have a comment including: |
105 | | - |
106 | | - * Affected browser(s) |
107 | | - * Short description of the bug / behavior |
108 | | - * Link to external reference (article, bug report, spec issue) |
109 | | - |
110 | | -### 3.2 Text scaling / mobile |
111 | | - |
112 | | -* **UFX-010**: `html` MUST include `text-size-adjust` settings: |
113 | | - |
114 | | - ```css |
115 | | - @layer fixes { |
116 | | - html { |
117 | | - -moz-text-size-adjust: 100%; |
118 | | - -webkit-text-size-adjust: 100%; |
119 | | - text-size-adjust: 100%; |
120 | | - } |
121 | | - } |
122 | | - ``` |
123 | | - |
124 | | - Vendor prefixes: |
125 | | - - `-moz-`: Firefox on Android |
126 | | - - `-webkit-`: Safari (iOS/macOS), Chrome, Edge |
127 | | - |
128 | | -* **UFX-011**: The use of `text-size-adjust` MUST be documented with reference to Mobile Safari font-size inflation and related articles. |
129 | | - |
130 | | -### 3.3 Motion / `prefers-reduced-motion` |
131 | | - |
132 | | -* **UFX-020**: There MUST be a block reacting to `@media (prefers-reduced-motion: reduce)`. |
133 | | - |
134 | | -* **UFX-021**: Minimal requirement: |
135 | | - |
136 | | - ```css |
137 | | - @layer fixes { |
138 | | - @media (prefers-reduced-motion: reduce) { |
139 | | - * { |
140 | | - scroll-behavior: auto !important; |
141 | | - } |
142 | | - } |
143 | | - } |
144 | | - ``` |
145 | | - |
146 | | -* **UFX-022**: Additional reductions (e.g. `animation-duration`, `transition-duration`) are optional and MUST be clearly commented if implemented. |
147 | | - |
148 | | -### 3.4 Hidden attribute |
149 | | - |
150 | | -* **UFX-050**: The `[hidden]` attribute MUST reliably hide elements: |
151 | | - |
152 | | - ```css |
153 | | - @layer fixes { |
154 | | - [hidden] { |
155 | | - display: none !important; |
156 | | - } |
157 | | - } |
158 | | - ``` |
159 | | - |
160 | | - The `!important` ensures the attribute works even when `display` is set by other CSS rules. |
161 | | - |
162 | | ---- |
163 | | - |
164 | | -## 4. Layer `elements` |
165 | | - |
166 | | -*(Previously “components”; intentionally narrower in scope.)* |
167 | | - |
168 | | -### 4.1 General |
169 | | - |
170 | | -* **ELT-001**: Layer name MUST be `elements`. |
171 | | -* **ELT-002**: Goal: minimal, semantically sensible HTML element defaults; no compound UI components. |
172 | | -* **ELT-003**: `elements` MUST be fully optional (e.g. separate file; integrator can choose not to import). |
173 | | - |
174 | | -### 4.2 Basic HTML elements |
175 | | - |
176 | | -* **ELT-010**: `a` elements MAY be slightly adjusted (e.g. `text-decoration-skip-ink: auto;`) but MUST remain clearly recognizable as links. |
177 | | -* **ELT-011**: `h1`–`h6`, `p` MUST NOT receive additional margins in `elements` (spacing systems are out of scope for v1; only the global 0-margins from `reset` apply). |
178 | | -* **ELT-012**: `ul`, `ol`, `dl` MUST keep `list-style` defaults; margin/padding are already 0 from `reset`. |
179 | | - |
180 | | -### 4.3 Font stacks (system UI & monospace, including emoji) |
181 | | - |
182 | | -* **ELT-020**: `:root` MUST define `--font-sans` as a modern system font stack including emoji fonts, for example: |
183 | | - |
184 | | - ```css |
185 | | - :root { |
186 | | - --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", |
187 | | - Roboto, "Helvetica Neue", Arial, sans-serif, |
188 | | - "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", |
189 | | - "Noto Color Emoji"; |
190 | | - } |
191 | | - ``` |
192 | | - |
193 | | -* **ELT-021**: `body` MUST use `font-family: var(--font-sans);`. |
194 | | - |
195 | | -* **ELT-022**: `:root` MUST define `--font-mono` as a modern monospace stack, e.g.: |
196 | | - |
197 | | - ```css |
198 | | - :root { |
199 | | - --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, |
200 | | - Consolas, "Liberation Mono", "Courier New", monospace; |
201 | | - } |
202 | | - ``` |
203 | | - |
204 | | -* **ELT-023**: `code`, `pre`, `kbd`, `samp` MUST use `font-family: var(--font-mono);`. |
205 | | - |
206 | | -* **ELT-024**: Emoji / emoticons MUST remain properly rendered via the emoji fonts in `--font-sans`; the default stack MUST NOT omit emoji-capable fonts. |
207 | | - |
208 | | -### 4.4 Hanging punctuation |
209 | | - |
210 | | -* **ELT-027**: `:root` MAY enable `hanging-punctuation: first last` for cleaner text blocks. |
211 | | - |
212 | | -* **ELT-028**: Form elements (`input`, `textarea`, `output`) and code elements (`pre`, `code`, `kbd`, `samp`) MUST disable hanging punctuation to prevent text cutoff and scrollbar issues: |
213 | | - |
214 | | - ```css |
215 | | - input, textarea, output, pre, code, kbd, samp { |
216 | | - hanging-punctuation: none; |
217 | | - } |
218 | | - ``` |
219 | | - |
220 | | -### 4.5 Typography scope in v1 |
221 | | - |
222 | | -* **ELT-030**: v1 MUST NOT define fluid typography, scales, or `clamp()`-based font sizing. |
223 | | -* **ELT-031**: v1 MUST NOT define global type scales (heading hierarchies, rhythm systems, etc.); only default UA behavior + base font family. |
224 | | - |
225 | | -### 4.5 Scroll margin for anchor links |
226 | | - |
227 | | -* **ELT-050**: Targeted elements (`:target`) SHOULD have scroll margin for better UX: |
228 | | - |
229 | | - ```css |
230 | | - @layer elements { |
231 | | - :target { |
232 | | - scroll-margin-block: 5ex; |
233 | | - } |
234 | | - } |
235 | | - ``` |
236 | | - |
237 | | -### 4.6 Intrinsic size animations |
238 | | - |
239 | | -* **ELT-060**: When motion is allowed, `interpolate-size` MAY be enabled: |
240 | | - |
241 | | - ```css |
242 | | - @layer elements { |
243 | | - @media (prefers-reduced-motion: no-preference) { |
244 | | - :root { |
245 | | - interpolate-size: allow-keywords; |
246 | | - } |
247 | | - } |
248 | | - } |
249 | | - ``` |
250 | | - |
251 | | - This enables CSS animations to/from `height: auto` and similar intrinsic sizes. |
252 | | - |
253 | | ---- |
254 | | - |
255 | | -## 5. Web Components & third-party systems |
256 | | - |
257 | | -* **WC-001**: The reset MUST NOT rely on Shadow DOM-specific selectors (`::part`, `::slotted`) or modify styles inside component shadow trees. |
258 | | -* **WC-002**: The reset MUST be written so that it does not unexpectedly break Custom Elements or Web Component libraries (no opinionated styling on unknown tags). |
259 | | -* **WC-003**: Because of Web Component and slot behavior, box sizing inheritance patterns (see RST-021) MUST be avoided; direct `box-sizing` is required. |
260 | | - |
261 | | ---- |
262 | | - |
263 | | -## 6. Explicit non-goals / constraints |
264 | | - |
265 | | -* **NG-001**: No global utility classes (see LAY-005/006). |
266 | | -* **NG-002**: No full UI components (buttons, cards, modals, etc.) in this project. |
267 | | -* **NG-003**: v1 MUST be plain CSS (no required SCSS/LESS/PostCSS features). |
268 | | -* **NG-004**: v1 MUST NOT define build-tool configurations (bundling options, “only-reset” builds, etc.); build tooling is out of scope for this version. |
| 77 | +For detailed implementation notes and alignment with other CSS resets, |
| 78 | +see the inline comments in each CSS file and `docs/css-reset-comparison.md`. |
0 commit comments