Developer Tool
Stylesheet Link Generator
Link tag snippet for external CSS files. Use it online on EasyTools99.
Tool area
Everything runs in the browser.
Reference results
| Input | Result |
|---|---|
Stylesheet address = https://cdn.example.com/app.css | <link rel="stylesheet" href="https://cdn.example.com/app.css"> |
Stylesheet address = /assets/print.css | <link rel="stylesheet" href="/assets/print.css"> |
Stylesheet address = ../css/theme.css | <link rel="stylesheet" href="../css/theme.css"> |
Stylesheet address = styles/calendar.css | <link rel="stylesheet" href="styles/calendar.css"> |
Stylesheet address = /static/exhibition.css | <link rel="stylesheet" href="/static/exhibition.css"> |
Stylesheet address = https://example.org/assets/typography.css | <link rel="stylesheet" href="https://example.org/assets/typography.css"> |
How it works
The generator puts the address in the href of a link element with rel=”stylesheet” . Place the output in the page head. The browser resolves the file location differently depending on whether you use an absolute URL or a document-relative path.
Using the result
For a document in a subdirectory, a leading slash resolves from the root of the base address. A path without that slash resolves relative to the document or any specified base URL. Preview at the final page location and check which response the browser received. A successful response may still be a fallback HTML page if the path is wrong, so check that it is CSS and that a known element actually picks up the expected rule.
Worked examples
- Load the shared styles from a static asset domain. A developer verifies the asset host responds before adding the link to shared templates.
- Link to a stylesheet from the site root. An editor tests the site-root path on a page published in a subdirectory.
- Resolve a relative path from a nested document. A maintainer tests the relative path from its nested page before copying it elsewhere.
Common mistakes
- A file called print.css applies to all media unless the tag specifies media=”print” .
- Relative addresses resolve against the document’s base URL.
- Check the response status and CSS MIME type. Avoid pasting the tag into visible article text.
FAQ
How do I link a CSS file in HTML?
Put the generated link element in the head and check that its href points to the stylesheet.
How do I link a print stylesheet?
Put it in the head and add media="print" to restrict its use to printing.
Which path works across pages at different depths?
A site-root path or absolute URL keeps the page depth from changing the destination.
