Skip to content or main menu

CSS print stylesheet intricacy 1

This caused me much frustration. So for the record, don’t ever include a title attribute on an HTML <link> element.

This may not come into play in most situations (I’ve never run into the problem before), but if the CSS file you’re linking to is for print (as opposed to screen) it may break the link and your print styles will not be rendered.

For example, this will work fine:

<link rel=“stylesheet” href=“print.css” type=“text/css” media=“print” />

but this will not:

<link title=“Print stylesheet for example.com” rel=“stylesheet”
href=“print.css” type=“text/css” media=“print” />

I don’t know why, but if you have the title attribute (which is not actually valid according to the W3C anyway) your page will not respect the rules in your print stylesheet.

I tested this in Firefox3 and Safari3 on Mac. That’s all I’ve got. Leave a comment if you’ve had any experiences similar to this.

Some comments...

  • Why would you need add a title anyway? Other than for personal reference, what good is it as that tag isn't rendered itself rather than it pulls in a file for specific use.

    But that's probably me just not knowing what I'm talking about anyway.

    Michael says:

Add your own comment...

preferably your real name
will be kept safe
got a website? (http://domain.com)
be nice