I learnt an important lesson today about the <link> tag. I had a XHTML Strict that looked like this:


<link rel="stylesheet" type="text/css" media="print"
title="Design for print" href="/print.css" />

And every time I tried to print the page it did not correctly incorporate the print.css file. The file gets downloaded by the client but not incorporated. After a lot of trial and errors and testing I finally discovered why. The title attribute stops the link tag from working.

The correct way to declare a link tag for a media="print" is to do the following:


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

Hopefully this will help someone else getting into the same pickle as I was in.

Comments

kent

helvete vad tråkig sida. jag kräks. hoppas du hade en trvlig kinatrip. tjock.

Anonymous

Hi for me when i use this link tag, the url is printing when i gave print as follows.
<html>
<head>
<link rel=alternate media=print href="http://someserver/abc.doc">
</head>
<body onload=window.print()>
</body>
</html>

Lakshmi Ramya

Hi for me when i use this link tag, the url is printing when i gave print as follows.
<html>
<head>
<link rel=alternate media=print href="http://someserver/abc.doc">
</head>
<body onload=window.print()>
</body>
</html>

Your email will never ever be published.

Previous:
Ask Yahoo "What state do the Simpsons live in?" January 5, 2006 Misc. links
Next:
My new years resolution 2006 January 9, 2006 Wondering
Related by category:
Fastest way to find out if a file exists in S3 (with boto3) June 16, 2017 Web development
Be very careful with your add_header in Nginx! You might make your site insecure February 11, 2018 Web development
<datalist> looks great on mobile devices August 28, 2020 Web development
How to get all of MDN Web Docs running locally June 9, 2021 Web development
Related by keyword:
mincss "Clears the junk out of your CSS" January 21, 2013 Python, Web development
This site is now 100% inline CSS and no bytes are wasted March 5, 2013 Python, Web development, Django
Find print statements in Python code April 12, 2005 Python, Linux
Tip: Printer friendly pages with Page Templates in Zope March 24, 2008 Zope