Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Node.js

Using CSS in Express.js

Serve CSS and other static assets with express.static from a public folder.

Using CSS in Express.js — a practical guide to Express static CSS with clear examples you can reuse in real projects.

Using CSS in Express.js — 37/55 in the Node.js series. Full playlist companion: Node.js complete course on YouTube. Prefer one article? Read the complete Node.js tutorial.

Short description

Put CSS/JS/images in `public/` and mount `express.static` so browsers can load `/style.css` and similar assets.

Static files

const path = require('path');
app.use(express.static(path.join(__dirname, 'public')));
// public/style.css -> http://localhost:3000/style.css

Leave a reply

Your email address will not be published. Required fields are marked *