Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

referencing CSS

Tags:

html

css

I would like to construct an HTML link element referencing a CSS file and I would like to use the same reference from multiple documents.

For example, my CSS file is in: {root}/style/style.css

For files in {root}, I use: <link type="text/css" rel="stylesheet" href="style/style.css" /> But for files in {root}/inc, I have to use <link type="text/css" rel="stylesheet" href="../style/style.css" />

Is there a reference to {root} that I can use: something like:

<link type="text/css" rel="stylesheet" href="{root}/style/style.css" />

Sorry for noob question and thanks!


2 Answers

A simple / usually means "start from root"

like image 140
Sampson Avatar answered Jan 22 '26 18:01

Sampson


Just start the URL with a slash, the {root} is implicit:

<link type="text/css" rel="stylesheet" href="/style/style.css" />
like image 32
Paige Ruten Avatar answered Jan 22 '26 18:01

Paige Ruten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!