You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**i18next** via `data-i18n` attributes: `<span data-i18n="key"></span>`
114
114
-**ES6 modules** throughout (`import`/`export`)
115
115
116
+
## CSS Best Practices
117
+
118
+
**Core Principle: Let the Browser Do Its Job of Handling Sizes**
119
+
120
+
Adding CSS to force specific sizes consistently causes problems. Removing that CSS and letting the browser calculate natural dimensions consistently produces better results.
121
+
122
+
### ❌ Don't Do This
123
+
124
+
```css
125
+
/* Don't force widths on containers */
126
+
.controls { width: 285px; }
127
+
128
+
/* Don't force button widths */
129
+
.button { width: 49%; }
130
+
131
+
/* Especially Don't use pixels for font sizes! */
132
+
.text { font-size: 16px; }
133
+
```
134
+
135
+
**Problems caused:**
136
+
- Fixed widths create cramped layouts, overlaps, and wasted space
137
+
- Forced button widths look unnatural
138
+
- Pixel font sizes don't scale across different display densities (200 DPI vs 800 DPI)
139
+
- Breaks user font size preferences and accessibility
140
+
141
+
### ✅ Do This Instead
142
+
143
+
```css
144
+
/* Let containers size naturally */
145
+
.controls { width: fit-content; }
146
+
/* Or just don't set width at all */
147
+
148
+
/* Let buttons size based on content */
149
+
/* Don't set width on buttons */
150
+
151
+
/* Use relative units for fonts */
152
+
.text { font-size: 1.2em; }
153
+
/* Or don't set font-size and use defaults */
154
+
```
155
+
156
+
**Results:**
157
+
- Layouts adapt naturally to content
158
+
- Elements look properly proportioned
159
+
- Text scales correctly across devices
160
+
- Respects user preferences
161
+
162
+
### The Pattern to Recognize
163
+
164
+
If you're writing CSS to force dimensions and encountering layout problems:
165
+
166
+
1.**Stop adding more CSS** to "fix" it
167
+
2.**Remove the size constraints** causing the problem
168
+
3.**Let the browser calculate** natural dimensions
169
+
4.**Only add back** minimal constraints if absolutely required
170
+
171
+
**Most of the time, removing CSS produces better results than adding more CSS.**
172
+
173
+
### When to Set Sizes
174
+
175
+
Only force sizes when there's a genuine need:
176
+
- Images/icons requiring exact dimensions
177
+
-`max-width` for text readability (e.g., `max-width: 80ch`)
178
+
- Specific design requirements (but question if they're necessary)
179
+
180
+
Use modern layout tools:
181
+
-**Flexbox** for flexible layouts with `gap`, `justify-content`, `align-items`
182
+
-**Grid** for two-dimensional layouts with `grid-template-columns`, `gap`
183
+
-**fit-content**, **auto**, **%** instead of fixed pixels
184
+
185
+
### Real Examples from LED Strip Redesign (2026-01-28)
186
+
187
+
All three of these problems were fixed by **removing CSS**, not adding more:
0 commit comments