Styles should not be referenced by a

(If you don’t work with HTML, this next post will be of no interest to you.)

Rant: the way external CSS stylesheets are included in HTML now is not logical nor convenient.
So: <link type="test/css" href="(...).css" rel="stylesheet" /> is wrong,
it should be <style type="text/css" src="(...).css" />.

Why?

css Zen Garden
Because src is for now, href is for later

In a HTML page, there are a number of files (URLs) that have to be fetched to display:

  • any text in the document, within <h1>, <p> or <div> tags or not
  • any images, specified as <img src=”” /> (always external)
  • any iframes, specified as <iframe src=”” /> (always external)
  • any javascript, specified as <script src=”” /> (external or in-line)

There are also links to other URLs that are not for now: maybe one click away, maybe just there to be interpreted by the web browser:

  • anchor links, specified as <a href=””></a>
  • links: prev/next, archive links, feed link, specified as <link rel=”” href=”” />

So: you need the src="" referenced files immediately, and the href="" ones not. The way stylesheets are referenced now breaks this logic.

Because <style> is for stylesheets

Why can you embed in-line CSS style information within <style> tags, but not external stylesheets? Compare that to Javascript:

Inline JS: <script>...</script> and
External JS: <script src="" />

That makes sense. The same should be possible for <style>. The way it works now is counter-intuitive and antiquated. So please add it to XHTML 1.1.

3 thoughts on “Styles should not be referenced by a

  1. Mark

    Maar het is toch nu reeds zo, ofwel doe je het via “link” met href, ofwel doe je het via @import met url.
    De tweede manier zal wel de standaard worden.

Leave a Reply

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