2026-02-07 19:14:13 +01:00
# Styling
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
FolderWeb uses modern CSS — no preprocessors, no build steps. Edit CSS files directly and refresh.
2025-11-27 23:01:02 +01:00
## Where Styles Live
```
custom/
2026-02-07 19:14:13 +01:00
└── styles/
└── base.css # Your main stylesheet
```
Page-specific styles can be placed alongside content:
```
content/portfolio/
├── index.md
└── styles.css # Loaded only on this page
2025-11-27 23:01:02 +01:00
```
**Loading order:**
2026-02-07 19:14:13 +01:00
1. `custom/styles/base.css` — always loaded
2. Page-specific `styles.css` — if present in the content directory
2025-11-27 23:01:02 +01:00
## Editing the Main Stylesheet
2026-02-07 19:14:13 +01:00
Edit `custom/styles/base.css` for site-wide styles:
2025-11-27 23:01:02 +01:00
```css
:root {
--color-primary: oklch(60% 0.15 250);
--color-text: oklch(20% 0 0);
--color-bg: oklch(98% 0 0);
--font-base: system-ui, -apple-system, sans-serif;
--font-mono: 'SF Mono', Monaco, monospace;
}
body {
font-family: var(--font-base);
color: var(--color-text);
background: var(--color-bg);
line-height: 1.6;
}
```
2026-02-07 19:14:13 +01:00
## CSS Variables
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
Define design tokens as variables, use them throughout:
2025-11-27 23:01:02 +01:00
```css
:root {
--color-accent: oklch(65% 0.2 150);
--radius-sm: 0.25rem;
--shadow: 0 2px 8px oklch(0% 0 0 / 0.1);
}
.button {
background: var(--color-accent);
border-radius: var(--radius-sm);
box-shadow: var(--shadow);
}
```
2026-02-07 19:14:13 +01:00
## OKLCH Colors
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
FolderWeb's default styles use OKLCH for perceptually uniform colors:
2025-11-27 23:01:02 +01:00
```css
2026-02-07 19:14:13 +01:00
--color: oklch(65% 0.1 250);
2025-11-27 23:01:02 +01:00
```
2026-02-07 19:14:13 +01:00
Format: `oklch(lightness chroma hue / alpha)`
2025-11-27 23:01:02 +01:00
- **Lightness:** 0% (black) to 100% (white)
- **Chroma:** 0 (gray) to ~0.4 (vivid)
2026-02-07 19:14:13 +01:00
- **Hue:** 0– 360 degrees
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
## CSS Nesting
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
Nest related styles without a preprocessor:
2025-11-27 23:01:02 +01:00
```css
.card {
padding: 1rem;
& h2 {
margin-top: 0;
}
& p {
color: var(--color-text-muted);
}
& :hover {
box-shadow: var(--shadow-lg);
}
}
```
2026-02-07 19:14:13 +01:00
## Fluid Typography
2025-11-27 23:01:02 +01:00
Responsive sizing without media queries:
```css
h1 {
font-size: clamp(2rem, 5vw, 4rem);
}
```
2026-02-07 19:14:13 +01:00
## Grid Layout
2025-11-27 23:01:02 +01:00
```css
.page-layout {
display: grid;
grid-template-columns: 1fr min(65ch, 100%) 1fr;
gap: 2rem;
& > * {
grid-column: 2;
}
& > .full-width {
grid-column: 1 / -1;
}
}
```
2026-02-07 19:14:13 +01:00
## Classless CSS
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
FolderWeb defaults to styling HTML elements directly rather than relying on classes. Since content comes from Markdown and HTML files, this means most content is styled without any classes:
2025-11-27 23:01:02 +01:00
```css
article {
max-width: 65ch;
margin: 0 auto;
& h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
}
& p {
line-height: 1.7;
}
}
```
2026-02-07 19:14:13 +01:00
Use classes when you need component variants, JavaScript hooks, or utility overrides.
2025-11-27 23:01:02 +01:00
## Page-Specific Styles
2026-02-07 19:14:13 +01:00
Add a `styles.css` file to a content directory:
2025-11-27 23:01:02 +01:00
```
content/portfolio/
├── index.md
└── styles.css
```
```css
.portfolio-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
```
2026-02-07 19:14:13 +01:00
FolderWeb loads it automatically with cache-busting:
2025-11-27 23:01:02 +01:00
```html
2026-02-07 19:14:13 +01:00
< link rel = "stylesheet" href = "/portfolio/styles.css?v=abc123" >
2025-11-27 23:01:02 +01:00
```
2026-02-06 18:47:23 +01:00
## Page-Specific Scripts
2026-02-07 19:14:13 +01:00
Add a `script.js` file to a content directory for progressive enhancement:
2026-02-06 18:47:23 +01:00
```
content/portfolio/
├── index.md
└── script.js
```
2026-02-07 19:14:13 +01:00
Loaded automatically with `defer` :
2026-02-06 18:47:23 +01:00
```html
2026-02-07 19:14:13 +01:00
< script defer src = "/portfolio/script.js?v=abc123" > < / script >
2026-02-06 18:47:23 +01:00
```
2025-11-27 23:01:02 +01:00
## Dark Mode
2026-02-07 19:14:13 +01:00
Use CSS variables with `prefers-color-scheme` :
2025-11-27 23:01:02 +01:00
```css
:root {
--color-bg: oklch(98% 0 0);
--color-text: oklch(20% 0 0);
}
@media (prefers-color-scheme: dark) {
:root {
--color-bg: oklch(15% 0 0);
--color-text: oklch(95% 0 0);
}
}
```
## Responsive Design
2026-02-07 19:14:13 +01:00
Prefer fluid CSS over fixed breakpoints:
2025-11-27 23:01:02 +01:00
```css
.container {
width: min(90%, 1200px);
padding: clamp(1rem, 3vw, 3rem);
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
gap: clamp(1rem, 3vw, 2rem);
}
```
2026-02-07 19:14:13 +01:00
Use media queries only when layout needs to change fundamentally (e.g., sidebar position).
2025-11-27 23:01:02 +01:00
## Cache Busting
2026-02-07 19:14:13 +01:00
FolderWeb versions CSS files with MD5 hashes automatically:
2025-11-27 23:01:02 +01:00
```html
< link rel = "stylesheet" href = "/custom/styles/base.css?v=a1b2c3d4" >
```
2026-02-07 19:14:13 +01:00
When you edit your CSS, the hash changes and browsers fetch the new version.
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
## Next Steps
2025-11-27 23:01:02 +01:00
2026-02-07 19:14:13 +01:00
- [Templates ](03-templates.md ) — Control HTML structure and layout
- [Internationalization ](../03-reference/04-internationalization.md ) — Multi-language support