- Simplicity by design

ASP.NET Themes and print style sheet


I ran into an issue where I need to specify print css for my ASP.NET Application. In general, we specify print style sheet by setting the media attribute to print

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

But in my case I was using ASP.NET Themes where we won’t specify the style sheets in the markup. ASP.NET picks it up automatically from the themes folder. I don’t want to place & link print.css from an another folder. Then I came across a neat trick where we can specify the media type right inside the style sheet as below.

@media print {
body { font-size: 10pt }
}

Share
  • Turn this article into a PDF!
blog comments powered by Disqus