Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

how can we attach CSS styling to a HTML document ?


3 ways to apply CSS


method 1 : a separate CSS

this is the preferred method

Loading...

URLs

where


URL variants

there are many variants in the way to build a URL, and we’ll touch on that during the course, but for example


relative URLs

it is possible to omit some parts of the URL;
and that’s exactly what we’ve done when we wrote href="hello.css" in our <head> above

imagine if you have loaded a document as, say https://hostname.io/the/path/to/content
then from within that document:

(and the same goes with the file:/// URL scheme of course)


method 2 : inline in html

back to the topic of injecting CSS in the page

Loading...

method 3: hardwired with style=

Loading...

practice


practice (continued)


the browser cache

for performance reasons primarily :

beware of that during development


how to deal with it

a couple hints and workarounds