#3 — Where to write my CSS

Simple CSS — the beginner’s guide to styling the web.

Stephen Pal-George
The Code Less Travelled

--

TL;DR

You can write your styles directly within your HTML document, but don’t! There’s a better way: stylesheets. We can write standalone .css files and then connect them to our HTML documents with a <link> tag.

Photo by Andrew Neel on Unsplash

There’s one really important question that we haven’t touched upon yet. We’re assuming that you’ve got some HTML that you want to style…well, where do you write your styles? And how do you get your HTML document to know about them and apply them to its content?

There’s a few ways to answer these questions, and we’ll cover all the basics in this article.

N.B. for now, we’re assuming you simply have some markup that you want to style — this article does not consider styling of a web app made with a modern front-end framework like react or svelte etc. The styling solutions for these are manifold and overwhelming for a beginner.

The Setup

So, you’re building an awesome website. You make a directory somewhere on your computer to store all the code and, inside that directory, you create an index.html file. This is a standardised file name that any web server would expect to find, meaning, when you come to deploy your website, you should be able to…

--

--

Stephen Pal-George
The Code Less Travelled

I'm a front end developer by day. I love patterns and anything interesting. Writing about code and theology...for now...