# Styling Your Site
FolderWeb embraces modern CSS—no preprocessors, no build steps, just the good stuff browsers support today. Let's make your site look exactly how you want.
## Where Styles Live
FolderWeb has a simple style hierarchy:
```
custom/
├── styles/
│ ├── base.css # Your main stylesheet
│ └── custom-theme.css # Additional stylesheets (optional)
└── content/
└── my-page/
└── styles.css # Page-specific styles (optional)
```
**Loading order:**
1. `custom/styles/base.css` — Your main styles (always loaded)
2. Page-specific `styles.css` — If it exists in the content directory
## Editing the Main Stylesheet
Start by editing `custom/styles/base.css`. This is where your site-wide styles live.
**Default structure:**
```css
/* CSS Variables (Design Tokens) */
: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;
--spacing-unit: 1rem;
}
/* Base Typography */
body {
font-family: var(--font-base);
color: var(--color-text);
background: var(--color-bg);
line-height: 1.6;
}
/* More styles... */
```
Edit these values to match your brand. No build step, no compilation—just save and refresh.
## Modern CSS Features
FolderWeb encourages using modern CSS features. Here's what you should know:
### CSS Variables (Custom Properties)
Define once, use everywhere:
```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);
}
```
### OKLCH Colors
Use modern color spaces for better color manipulation:
```css
/* Traditional RGB/HSL */
--old: rgb(100, 150, 200);
--old-hsl: hsl(210, 50%, 60%);
/* Modern OKLCH (better perceptual uniformity) */
--new: oklch(65% 0.1 250);
```
**Format:** `oklch(lightness chroma hue / alpha)`
- **Lightness:** 0% (black) to 100% (white)
- **Chroma:** 0 (gray) to ~0.4 (vivid)
- **Hue:** 0-360 degrees (color wheel)
### CSS Nesting
Nest related styles without preprocessors:
```css
.card {
padding: 1rem;
border-radius: 0.5rem;
& h2 {
margin-top: 0;
}
& p {
color: var(--color-text-muted);
}
&:hover {
box-shadow: var(--shadow-lg);
}
}
```
### Fluid Typography with `clamp()`
Responsive sizing without media queries:
```css
h1 {
/* Min 2rem, ideal 5vw, max 4rem */
font-size: clamp(2rem, 5vw, 4rem);
}
p {
/* Min 1rem, ideal 1.125rem, max 1.25rem */
font-size: clamp(1rem, 1.125rem, 1.25rem);
}
```
### Logical Properties
Use logical properties for better internationalization:
```css
/* Old way (assumes left-to-right) */
.old {
margin-left: 1rem;
padding-right: 2rem;
}
/* New way (respects text direction) */
.new {
margin-inline-start: 1rem;
padding-inline-end: 2rem;
}
```
**Common logical properties:**
- `margin-inline-start` / `margin-inline-end` (left/right in LTR)
- `margin-block-start` / `margin-block-end` (top/bottom)
- `padding-inline` / `padding-block`
- `inline-size` (width)
- `block-size` (height)
### Grid Layout
Use CSS Grid for layout (not flexbox for everything):
```css
.page-layout {
display: grid;
grid-template-columns: 1fr min(65ch, 100%) 1fr;
gap: 2rem;
& > * {
grid-column: 2;
}
& > .full-width {
grid-column: 1 / -1;
}
}
```
## Classless CSS Philosophy
FolderWeb defaults to **classless CSS**—styling HTML elements directly instead of adding classes everywhere.
**Good (classless):**
```html
Page Title
Content here.
```
```css
article {
max-width: 65ch;
margin: 0 auto;
& h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
}
& p {
line-height: 1.7;
}
}
```
**Less good (class-heavy):**
```html
Page Title
Content here.
```
**When to use classes:**
- Component variants (`.button-primary`, `.button-secondary`)
- JavaScript hooks (`.js-toggle`)
- Utility overrides (`.visually-hidden`)
## Page-Specific Styles
Add `styles.css` to a content directory for page-specific styling:
```
content/portfolio/
├── index.md
└── styles.css
```
**styles.css:**
```css
/* Scoped to this page only */
.portfolio-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
```
FolderWeb automatically loads and includes page-specific styles with cache-busting:
```html
```
## Page-Specific Scripts
For small progressive enhancements, you can add a `script.js` file to a content directory:
```
content/portfolio/
├── index.md
├── styles.css
└── script.js
```
**script.js:**
```js
// Small enhancement for this page only
document.querySelector('.portfolio-grid')?.addEventListener('click', (e) => {
// ...
});
```
FolderWeb automatically loads the script with `defer` (non-blocking) and cache-busting:
```html
```
The script tag is placed before `