<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Adam.Kahtava.com / AdamDotCom &#187; Themes and Skins</title>
	<atom:link href="http://adam.kahtava.com/journal/category/themes-and-skins/feed/" rel="self" type="application/rss+xml" />
	<link>http://adam.kahtava.com/journal</link>
	<description>A software development blog</description>
	<pubDate>Thu, 15 Jul 2010 17:00:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Good Parts of The ASP.NET Framework and Visual Studio</title>
		<link>http://adam.kahtava.com/journal/2008/05/31/the-good-parts-of-the-aspnet-framework-and-visual-studio/</link>
		<comments>http://adam.kahtava.com/journal/2008/05/31/the-good-parts-of-the-aspnet-framework-and-visual-studio/#comments</comments>
		<pubDate>Sat, 31 May 2008 21:56:37 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Musings]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,e724903b-65d4-4c94-a1bd-e704c9d80093.aspx</guid>
		<description><![CDATA[Douglas Crockford opens his latest book with these words:
Most programming languages contain good parts and bad parts. &#8230; [the language designers or architects] are usually powerless to do anything except heap more features on top of the existing pile of imperfections. And the new features do not always interact harmoniously, thus producing more bad parts. [...]]]></description>
			<content:encoded><![CDATA[<p>Douglas Crockford opens his latest book with these words:</p>
<blockquote><p><strong>Most programming languages contain good parts and bad parts</strong>. &#8230; [the language designers or architects] are usually powerless to do anything except heap more features on top of the existing pile of imperfections. And the new features do not always interact harmoniously, thus producing more bad parts. - <a href="http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742/">JavaScript: The Good Parts by Douglas Crockford</a></p></blockquote>
<p>His words can apply to all programming languages and frameworks. Like the Microsoft .NET Framework, Visual Studio, Java, and Eclipse.</p>
<p>Bad parts in the ASP.NET Framework and Visual Studio:</p>
<ul>
<li> ASP.NET Themes and Skins</li>
<li> The ASP.NET AJAX Framework</li>
<li> ASP.NET / Visual Studio Inline Style Properties</li>
<li> Visual Studio Design View</li>
<li> ASP.NET and Visual Studio&#8217;s over dependency on XML configuration files</li>
</ul>
<p>It would be great if someone wrote a book outlining the good parts of ASP.NET and Visual Studio. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2008/05/31/the-good-parts-of-the-aspnet-framework-and-visual-studio/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Reflection on Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 (A Final Conclusion)</title>
		<link>http://adam.kahtava.com/journal/2008/04/07/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-a-final-conclusion/</link>
		<comments>http://adam.kahtava.com/journal/2008/04/07/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-a-final-conclusion/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 23:19:54 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,42f9acf9-af59-44fd-aef5-8d3ab773d5ba.aspx</guid>
		<description><![CDATA[A couple years ago I was thrown into a web application that made heavy use of ASP.NET Themes and Skins. Prior to this I depended exclusively on Cascading Style Sheet (CSS) for my web development / web design needs. A first glance at ASP.NET Themes and Skins looked promising, but a number of flaws surfaced [...]]]></description>
			<content:encoded><![CDATA[<p>A couple years ago I was thrown into a web application that made heavy use of ASP.NET Themes and Skins. Prior to this I depended exclusively on Cascading Style Sheet (CSS) for my web development / web design needs. A first glance at ASP.NET Themes and Skins looked promising, but a number of flaws surfaced - see the links and issues listed at the end of this post.</p>
<p>In addition to these issues, here are a couple other considerations when thinking about ASP.NET Themes:</p>
<ul>
<li> Themes do not adequately separate the levels of concerns within your application. When using Themes all design related files are baked into the application. From a maintainability standpoint, this doesn&#8217;t bode well in large web applications. Hosting design related files on a single server or an external <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network">Content Delivery Network (CDN)</a> is an effective way for managing site wide UI updates and increasing a sites performance, ASP.NET Themes works against this technique.</li>
<li> Themes add unneeded complexity by obscuring the real technologies at work (CSS). Everything that ASP.NET Themes offer can be better achieved outside of the ASP.NET Theme Framework. Technologies like Cascading Style Sheets (CSS),Â  alternate Style Sheets, and JavaScript can achieve more than Themes can provide.</li>
<li> Themes are a server-side mechanism. Themes become a nuisance in client-side dependent, heavily dynamic, Web 2.0, DHTML, AJAX type web applications.</li>
<li> Themes discourage developers from learning more about web design and the technologies surrounding it. Themes offer a seemingly simple API, which shelters developers from the complexities of CSS and JavaScript, but sooner or later <a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html">The Law of Leaky Abstractions</a> comes into play and knowing the fundamentals of these technologies is a necessity.</li>
<li> Professional web designers don&#8217;t use ASP.NET Themes, CSS is the language of web designers.</li>
</ul>
<p>Default Skins on the other hand can be useful for defining consistent CSS hooks into common ASP.NET controls. It&#8217;s unfortunate that we can&#8217;t use Skins without Themes.</p>
<p><strong>Related posts:</strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Where it all Falls Apart</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder (Work Around #1)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s) (Work Around #2)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/">Defining the Load Order (Cascades) for CSS (Work Around #3)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style with Themes (Work Around #4)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/">Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2008/04/07/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-a-final-conclusion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Free: Win a Copy of Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages</title>
		<link>http://adam.kahtava.com/journal/2008/02/25/free-win-a-copy-of-professional-aspnet-20-design-css-themes-and-master-pages/</link>
		<comments>http://adam.kahtava.com/journal/2008/02/25/free-win-a-copy-of-professional-aspnet-20-design-css-themes-and-master-pages/#comments</comments>
		<pubDate>Mon, 25 Feb 2008 14:40:51 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Book]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Contest]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,8350b735-2367-413e-87cd-3ce717592130.aspx</guid>
		<description><![CDATA[Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages by Jacob Sanford is a great book for ASP.NET developers looking to expand their knowledge on the ASP.NET 2.0 Web Design front.  
 I&#39;ve read this book, re-read it, edited it, and would like to give it away - I was the Technical Editor. The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/0470124482?ie=UTF8&amp;tag=adamkahtavaap-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470124482"><img src="http://ecx.images-amazon.com/images/I/41Rc63UdxTL._AA240_SH20_.jpg" style="border: 0px none ; float: right;"></a><a href="http://www.amazon.com/gp/product/0470124482?ie=UTF8&amp;tag=adamkahtavaap-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470124482">Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages</a> by Jacob Sanford is a great book for ASP.NET developers looking to expand their knowledge on the ASP.NET 2.0 Web Design front.  </p>
<p> I&#39;ve read this book, re-read it, edited it, and would like to give it away - I was the Technical Editor. The books is like new and (did I mention) it&#39;s free!
<p class="MsoNormal"> <b>Contest Rules:</b>  </p>
<ul>
<li> <font size="4">Updated! Just Leave a comment with a valid email address!</font> </li>
</ul>
<ul>
<li> <strike>Post a 500 x 200 pixel image of something you&#39;re working on in the comments of this post - this image could be code, web design, or anything work related.</strike> </li>
<li> <strike>Include an optional description of your work</strike> </li>
<li> The winner will be chosen <strike>April 1st</strike> May 1st, they&#39;ll be drawn at random, and will be notified through email.</li>
<li> I pay for shipping.</li>
</ul>
<p> <i>* I&#39;ve included a sample entry in the comments. If you&#39;re looking for a great free photo editing application then try <a href="http://www.getpaint.net/">Paint.net</a>. If you&#39;re looking to host your image you might want to consider <a href="http://www.flickr.com/">Flickr</a> or <a href="http://photobucket.com/">Photobucket</a>.</i>  </p>
<p> <strike>Good Luck!</strike> </p>
<p> The contest has ended, and the winner is&#8230;.. <span class="tx"><b>Andrew Hinde</b>. </span>Nice!<br /> <hints id="hah_hints"> </hints></p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2008/02/25/free-win-a-copy-of-professional-aspnet-20-design-css-themes-and-master-pages/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</title>
		<link>http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/</link>
		<comments>http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/#comments</comments>
		<pubDate>Tue, 03 Apr 2007 00:49:15 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,cccb1beb-f995-47ca-92ba-137b7d73f082.aspx</guid>
		<description><![CDATA[ASP.NET 2.0 Themes have a couple design flaws, all of which center around the way Themes reference Cascading Style Sheets (CSS). I&#8217;ve been posting Theme and CSS related issues and work arounds as I encountered them, and in one of my first posts I outlined the possibility of using a VirtualPathProvider to ignore the CSS [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0 Themes have a couple design flaws, all of which center around the way Themes reference <a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets">Cascading Style Sheets (CSS)</a>. I&#8217;ve been posting Theme and CSS related issues and work arounds as I encountered them, and in one of my first posts I outlined the possibility of using a <a href="http://msdn2.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx">VirtualPathProvider</a> to ignore the CSS files within a directory. In this post I share <a href="http://www.linkedin.com/pub/3/703/412">David Marzo&#8217;s</a> implemented of this solution. This resolution resolves most of the issues surrounding Themes and CSS, and essentially puts the Cascades back into CSS.</p>
<p><strong>The Problem / Question:</strong><br />
ASP.NET 2.0 Themes automatically includes all the Style Sheets (.css files) found in the active Theme (App_Theme) directory into the Head of the rendered document. This severely limits the robust CSS language, and works against the last decade of Cascading Style Sheet progress. For more specific details on the problems with ASP.NET 2.0 Themes start reading the articles found <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">here</a>.</p>
<p><strong>A Solution / Work Around: </strong><br />
Add a custom <a href="http://msdn2.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx">VirtualPathProvider</a> to ignore the Style Sheets (CSS files) found in the App_Theme directory. For more background on this solution see <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">my article</a> and David Ebbo&#8217;s article titled <a href="http://blogs.msdn.com/davidebb/archive/2005/11/27/overriding-asp-net-combine-behavior-using-a-virtualpathprovider.aspx"> Overriding ASP.NET combine behavior using a VirtualPathProvider</a>.</p>
<p><strong>An example of the problem:</strong></p>
<p><strong></strong><strong>The directory structure:</strong><br />
<strong><img src="http://adam.kahtava.com/journal/images/blog/TPWSAT_Resolution.png" alt="" /></strong><br />
<em>Notice all the Style Sheets (.css files), there are more in the Adapters directory too.</em></p>
<p><strong><span style="text-decoration: underline;">Before</span> including the CustomVirtualPathProvider (code provided below) into the project&#8217;s build - the XHTML rendered by Themes:</strong></p>
<pre><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">="http://www.w3.org/1999/xhtml"</span> <span style="color: blue;">&gt;</span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">  &lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">title</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">The Problems With Themes and Skins in ASP.NET 2.0</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">title</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">    &lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">link</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/CSS/Adapters/ChangePassword.css"</span> <span style="color: red;">type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: blue;">/&gt; </span></span>

<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: #008000;">    ... The other 17 externally linked Style Sheets go here, they were removed to improve readability ...</span></span>

<span style="color: #008000;"> </span><span style="color: #008000;">    </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">link</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/CSS/PrinterFriendly.css"</span> <span style="color: red;">type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: blue;">/&gt;</span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">  &lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></pre>
<p><em>The Style Sheets are automagically inserted into the Head tag from the active Theme directory. Keep in mind that Internet Explorer has a 30 Style Sheet limitation (see article <a href="http://support.microsoft.com/kb/q262161">Q262161</a>).</em><br />
<strong></strong></p>
<p><strong><span style="text-decoration: underline;">After</span> including the CustomVirtualPathProvider (code provided below) into the project&#8217;s build - the XHTML rendered by Themes:</strong></p>
<pre><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">="http://www.w3.org/1999/xhtml"</span> <span style="color: blue;">&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">  &lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">title</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">The Problems With Themes and Skins in ASP.NET 2.0</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">title</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">  &lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></pre>
<p><em>Notice the complete lack of Style Sheets - ahhh simplicity is bliss, the very foundations of <a href="http://www.csszengarden.com/">CSS Zen Enlightenment</a>&#8230; :) Now we can manually include our Style Sheets, use Conditional Comments, and so on.<br />
</em></p>
<p><strong>The source code for the CustomVirtualPathProvider provided by <a href="http://www.linkedin.com/pub/3/703/412">David Marzo</a> in C#:<br />
</strong></p>
<pre><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">namespace</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Arfila.Web.Logic {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>[<span style="color: teal;">AspNetHostingPermission</span>(<span style="color: teal;">SecurityAction</span>.Demand,
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Level = <span style="color: teal;">AspNetHostingPermissionLevel</span>.Medium)]</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>[<span style="color: teal;">AspNetHostingPermission</span>(<span style="color: teal;">SecurityAction</span>.InheritanceDemand,
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Level = <span style="color: teal;">AspNetHostingPermissionLevel</span>.High)]</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: teal;">CustomVirtualPathProvider</span> : <span style="color: teal;">VirtualPathProvider</span> {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span><span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> AppInitialize() {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>     </span><span style="color: teal;">HostingEnvironment</span>.RegisterVirtualPathProvider(<span style="color: blue;">new</span> <span style="color: teal;">CustomVirtualPathProvider</span>());</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span><span style="color: blue;">public</span> CustomVirtualPathProvider() : <span style="color: blue;">base</span>() { }</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span><span style="color: blue;">private</span> <span style="color: blue;">bool</span> IsThemeDirectory(<span style="color: blue;">string</span> virtualPath) {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span>    </span><span style="color: teal;">String</span> checkPath = <span style="color: teal;">VirtualPathUtility</span>.ToAppRelative(virtualPath);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>     </span><span style="color: blue;">return</span> checkPath.StartsWith(<span style="color: maroon;">"~/App_Themes/"</span>, <span style="color: teal;">
</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: teal;">StringComparison</span>.InvariantCultureIgnoreCase);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span><span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: teal;">VirtualDirectory</span> GetDirectory(<span style="color: blue;">string</span> virtualDir) {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>     </span><span style="color: blue;">if</span> (IsThemeDirectory(virtualDir)) {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>       </span><span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: teal;">ThemeDirectory</span>(Previous.GetDirectory(virtualDir));</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>     </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>     </span><span style="color: blue;">else</span> {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>       </span><span style="color: blue;">return</span> Previous.GetDirectory(virtualDir);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>     </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>   </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>[<span style="color: teal;">AspNetHostingPermission</span>(<span style="color: teal;">SecurityAction</span>.Demand,
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Level = <span style="color: teal;">AspNetHostingPermissionLevel</span>.Minimal)]</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>[<span style="color: teal;">AspNetHostingPermission</span>(<span style="color: teal;">SecurityAction</span>.InheritanceDemand,
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Level = <span style="color: teal;">AspNetHostingPermissionLevel</span>.Minimal)]</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: teal;">ThemeDirectory</span> : <span style="color: teal;">VirtualDirectory</span> {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: teal;">VirtualDirectory</span> _toFilter;</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">private</span> <span style="color: teal;">ArrayList</span> _children = <span style="color: blue;">new</span> <span style="color: teal;">ArrayList</span>();</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">private</span> <span style="color: teal;">ArrayList</span> _directories = <span style="color: blue;">new</span> <span style="color: teal;">ArrayList</span>();</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">private</span> <span style="color: teal;">ArrayList</span> _files = <span style="color: blue;">new</span> <span style="color: teal;">ArrayList</span>();</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: teal;">IEnumerable</span> Children {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span><span style="color: blue;">get</span> { <span style="color: blue;">return</span> _children; }</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: teal;">IEnumerable</span> Directories {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span><span style="color: blue;">get</span> { <span style="color: blue;">return</span> _directories; }</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: teal;">IEnumerable</span> Files {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span><span style="color: blue;">get</span> { <span style="color: blue;">return</span> _files; }</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">public</span> ThemeDirectory(<span style="color: teal;">VirtualDirectory</span> toFilter) : <span style="color: blue;">base</span>(toFilter.VirtualPath) {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span>_toFilter = toFilter;</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span>BuildChild();</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span><span style="color: blue;">private</span> <span style="color: blue;">void</span> BuildChild() {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span><span style="color: blue;">foreach</span> (<span style="color: teal;">VirtualDirectory</span> dirToFilter <span style="color: blue;">in</span> _toFilter.Directories) {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span><span style="color: teal;">ThemeDirectory</span> themeDir = <span style="color: blue;">new</span> <span style="color: teal;">ThemeDirectory</span>(dirToFilter);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span>_children.Add(themeDir);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span>_directories.Add(themeDir);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span><span style="color: blue;">foreach</span> (<span style="color: teal;">VirtualFile</span> fileToFilter <span style="color: blue;">in</span> _toFilter.Files) {
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span><span style="color: blue;">string</span> fileExtension = </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: teal;">VirtualPathUtility</span>.GetExtension(fileToFilter.VirtualPath).TrimStart(<span style="color: maroon;">'.'</span>);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>  </span><span>      </span><span style="color: blue;">if</span> (<span style="color: blue;">string</span>.Compare(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">fileExtension</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">, <span style="color: maroon;">"css"</span>, <span style="color: blue;">true</span>) != 0) {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>          </span>_children.Add(fileToFilter);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>          </span>_files.Add(fileToFilter);</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span><span style="color: blue;">else</span> {</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>          </span><span style="color: green;">//archivo .css no incluir</span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>        </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>      </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>    </span>}</span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>  </span>}
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></pre>
<p><em>Some of the code has been modified for readability, download the original source code <a href="http://adamdotcom-script.googlecode.com/svn/trunk/Etcetera/CustomVirtualPathProvider.cs">here</a>.</em></p>
<p><strong>Note:</strong><em> In order to use this VPP you&#8217;ll have to copy the code above into a new class in your App_Code directory.</em></p>
<div style="border: 1px solid #ccccee; padding: 5px; background-color: #ffffdd;"><strong>Caveat: </strong><em>If a Web site is precompiled for deployment, content provided by a VirtualPathProvider instance is not compiled, and no VirtualPathProvider instances are used by the precompiled site.</em> - Taken from the article titled <a href="http://msdn2.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx">VirtualPathProvider Class</a> on MSDN.</div>
<p><strong><br />
Conclusion:</strong> This is one of the nicest work arounds or resolution to the issues surrounding ASP.NET 2.0 Themes. It allows us to leverage the power of ASP.NET 2.0 default Skins, allows us to logically group design related resources (Style Sheets, images, default Skins, videos, etc&#8230;) in the App_Theme directory, allows us to control the loading order (cascades) of style sheets, allows us to use <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">Conditional Comments</a>, to define <a href="http://www.w3.org/TR/REC-CSS2/media.html">Media Types</a>, to override / inherit Styles, and to continue using CSS as it&#8217;s intended. In addition we can now easily integrate the <a href="http://www.asp.net/cssadapters/">ASP.NET 2.0 CSS Friendly Control Adapters</a> into our web applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/feed/</wfw:commentRss>
		</item>
		<item>
		<title>In Favor of Using Style Elements / Embedded Style Sheets / Style Blocks / Style Tags or Whatever You Want To Call Them inside the HTML / XHTML Body.</title>
		<link>http://adam.kahtava.com/journal/2007/03/20/in-favor-of-using-style-elements-embedded-style-sheets-style-blocks-style-tags-or-whatever-you-want-to-call-them-inside-the-html-xhtml-body/</link>
		<comments>http://adam.kahtava.com/journal/2007/03/20/in-favor-of-using-style-elements-embedded-style-sheets-style-blocks-style-tags-or-whatever-you-want-to-call-them-inside-the-html-xhtml-body/#comments</comments>
		<pubDate>Tue, 20 Mar 2007 22:20:02 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[DOM]]></category>

		<category><![CDATA[Firebug]]></category>

		<category><![CDATA[Firefox]]></category>

		<category><![CDATA[IE]]></category>

		<category><![CDATA[Opera]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,fb97f8d5-0271-466f-a3f3-e09c53890ab0.aspx</guid>
		<description><![CDATA[I&#8217;ve been using Style Elements within the HTML Body tag to work around some of the design flaws presented in ASP.NET 2.0 Themes - see the second solution in this post for more details. I&#8217;ve been leary of using this method because it&#8217;s not a best practice, since it compromises the validity of the HTML [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.w3.org/TR/REC-CSS1#containment-in-html">Style Elements</a> within the HTML Body tag to work around some of the design flaws presented in ASP.NET 2.0 Themes - see the second solution in <a href="http://adam.kahtava.com/journal/c1575144-e460-464d-b993-259ce96135f4.aspx">this post</a> for more details. I&#8217;ve been leary of using this method because it&#8217;s not a best practice, since it compromises the validity of the HTML / XHTML document. I decided to do a little more research on this subject and made the following discoveries.</p>
<p><strong>Discoveries:</strong></p>
<ol>
<li> Some of the more complex web sites (<a href="http://amazon.com/">Amazon</a> and <a href="http://www.yahoo.com/">Yahoo!</a>) make use of Style Elements within the Body Element - see the source snippets below.</li>
<li> <a href="http://en.wikipedia.org/wiki/Gecko_%28layout_engine%29">Gecko</a> (<a href="http://en.wikipedia.org/wiki/Firefox">Firefox</a>, <a href="http://en.wikipedia.org/wiki/Flock_%28web_browser%29">Flock</a>, <a href="http://en.wikipedia.org/wiki/Mozilla">Mozilla</a>, etc&#8230;) based browsers automatically move Style Elements found within the Body Element into the Head Element and render the page as expected - see the rendered Document Object Model (DOM) image below.</li>
<li> <a href="http://en.wikipedia.org/wiki/Internet_Explorer">Internet Explorer</a> doesn&#8217;t move the Style Element into the Head Element, but renders the page as expected.</li>
<li> <a href="http://en.wikipedia.org/wiki/Opera_%28internet_suite%29">Opera</a>&#8230; well I wish I knew what Opera did, but the page renders as expected.</li>
</ol>
<p><strong>Source snippet from Amazon:</strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><br />
</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">table</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>Â Â Â  </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">td</span><span style="color: blue;">&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>Â  </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">tr</span><span style="color: blue;">&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">table</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;Â </p>
<p><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">.lol-hr-center</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> { <span style="color: red;">margin</span>: <span style="color: blue;">5px</span>; <span style="color: red;">border-top-width</span>: <span style="color: blue;">1px</span>; </span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">/* and so on&#8230; */</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></strong></p>
<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">div</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">id</span><span style="color: blue;">=&#8221;listoflists_data&#8221;</span> <span style="color: red;">style</span><span style="color: blue;">=&#8221;display:none&#8221;&gt; </span></span><br />
<em>Note how the Style element is located between the &lt;table&gt; and &lt;div&gt; tags.</em></p>
<p></span><br />
<strong>Source snippet from Yahoo!:</strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">h4</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">a</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">id</span><span style="color: blue;">=&#8221;paweather&#8221;</span> <span style="color: red;">class</span><span style="color: blue;">=&#8221;details&#8221;</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;r/wb/*-http://weather.yahoo.com/forecast/USKS0448_f.html&#8221;&gt;&lt;</span><span style="color: maroon;">span</span> <span style="color: red;">class</span><span style="color: blue;">=&#8221;icon&#8221;&gt;</span>Weather <span style="color: blue;">&lt;</span><span style="color: maroon;">b</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">strong</span><span style="color: blue;">&gt;</span>51<span style="color: red;">&amp;deg;</span><span style="color: blue;">&lt;/</span><span style="color: maroon;">strong</span><span style="color: blue;">&gt;</span>F<span style="color: blue;">&lt;/</span><span style="color: maroon;">b</span><span style="color: blue;">&gt;&lt;/</span><span style="color: maroon;">span</span><span style="color: blue;">&gt;&lt;/</span><span style="color: maroon;">a</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong>&lt;</strong></span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;&gt;</span><span style="color: maroon;">#patabs</span> <span style="color: maroon;">#weather</span> <span style="color: maroon;">.icon</span>{<span style="color: red;">background</span>:<span style="color: blue;">url(http://us.i1.yimg.com/us.yimg.com/i/us/we/31/b/26.gif)</span> <span style="color: blue;">3px</span> <span style="color: blue;">2px</span><span style="color: blue;">no-repeat</span>;}<span style="color: blue;">&lt;/</span><span style="color: maroon;">style</span><span style="color: blue;">&gt;</span></strong></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong></strong>&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">h4</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><br />
<em>Note how the Style element is located within the &lt;h4&gt; tag.</em><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> </span><br />
<strong>A snapshot of the <a href="http://en.wikipedia.org/wiki/Document_Object_Model">Document Object Model (DOM)</a> as seen through <a href="http://www.getfirebug.com/">Firebug</a>:</strong></p>
<blockquote><p><img src="http://adam.kahtava.com/journal/images/blog/StyleInBody1.png" alt="" /><br />
<em>Note the highlighted area references the Yahoo! source snippet from above.</em>Â<br />
<strong>Conclusion:</strong> Although the Style Element within the Body Element compromises the validity of a document, some of the leaders in web design and accessibility use this approach, so it may not be as big a work around or hack.</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2007/03/20/in-favor-of-using-style-elements-embedded-style-sheets-style-blocks-style-tags-or-whatever-you-want-to-call-them-inside-the-html-xhtml-body/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problems with Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 - Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</title>
		<link>http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/</link>
		<comments>http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 15:19:12 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,002ae3f5-6496-4d64-aab8-d3ccf498d7c7.aspx</guid>
		<description><![CDATA[In this post I outline a couple alternate ways of defining the CSS Print Media Type with Themes. ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on Cascading Style Sheets (CSS), but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I outline a couple alternate ways of defining the CSS Print <a href="http://www.w3.org/TR/REC-CSS2/media.html">Media Type</a> with Themes. ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on <a href="http://en.wikipedia.org/wiki/Css">Cascading Style Sheets (CSS)</a>, but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your application is even developed, instead I suggest sticking with CSS and perhaps using some default Skins that define CSS selectors like classes or IDs.</p>
<p><strong>The Problem / Question:</strong><br />
How can I use the CSS Print <a href="http://www.w3.org/TR/REC-CSS2/media.html">Media Type</a> with Themes? In the past I&#8217;ve used an <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.1">External Style Sheet</a> which defined the Print Media Type, but ASP.NET 2.0 omits the Media Type attribute when it automatically includes all my CSS files (from the active Theme directory) into the HTML Head tag.</p>
<p><strong>A Solution / Work Around:</strong><br />
The Print Media Type isn&#8217;t constrained to External Style Sheets and can be defined in the <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.2.3">Style Element</a>, in the <a href="http://www.w3.org/TR/CSS21/media.html#at-media-rule">@Media rule</a>, and even specified through the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">@Import rule</a>.</p>
<p><strong>An example of the problem:</strong></p>
<p><strong></strong><strong>The directory structure:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_5_VS05_SS1.png" alt="" /></p>
<p><strong>The rendered XHTML: </strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0<span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=<span style="color: #0000ff;">&#8220;App_Themes/Default/PrinterFriendlyStyleSheet.css&#8221;</span></span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=<span style="color: #0000ff;">&#8220;App_Themes/Default/StyleSheet.css&#8221;</span></span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><br />
<em>Note each externally linked Style Sheet lacks a media type.</em></p>
<p><strong>Our desired XHTML (using an Externally Linked Style Sheet and a Print Media Type) would have looked something like this: </strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=<span style="color: #0000ff;">&#8220;App_Themes/Default/PrinterFriendlyStyleSheet.css&#8221;</span></span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: red;">media</span><span style="color: blue;">=&#8221;all&#8221;</span><strong><span style="color: blue;"> </span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span>/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/PrinterFriendlyStyleSheet.css&#8221;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <strong><span style="color: red;">media</span><span style="color: blue;">=&#8221;print&#8221;</span></strong> <span>/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><br />
<em>Note the Media Type (<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong><span style="color: red;">media</span><span style="color: blue;">=&#8221;print&#8221;</span></strong></span>) in bold.</em></p>
<p><strong> The solutions:</strong></p>
<p><strong></strong><strong>Option 1. </strong>Use the <a href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule">Media Rule (@Media)</a> to define the print <a href="http://www.w3.org/TR/REC-CSS2/media.html#media-types">Media Type</a> inside an <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.3">Externally Linked</a> Style Sheet.</p>
<p><strong>An example:</strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">@Media</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Print {</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: maroon;">body</span> {</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">background-color</span>: <span style="color: blue;">#FFFFFF</span>;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>}</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: green;">/*&#8230; your CSS here &#8230;*/</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: maroon;">#Menu</span>, <span style="color: maroon;">#AdvertismentContainer</span> {</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">display</span>: <span style="color: blue;">none</span>;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>}</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: maroon;">#Content</span> {</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">width</span>: <span style="color: blue;">100%</span>;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span>}</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span><br />
<strong>Discussion:</strong> This is probably the best alternative to defining the Media Type in an Externally Linked Style Sheet - the other solutions introduce problems of their own.<br />
<strong></strong></p>
<p><strong>Option 2. </strong>Use the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">Import Rule (@Import)</a> to load your printer friendly Style Sheet from an alternate location and define a <a href="http://www.w3.org/TR/REC-CSS2/media.html#media-types">Media Type</a> - this involves removing your printer friendly Style Sheet from the Themes (App_Theme directory).</p>
<p><strong>An example:</strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">@Import</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> url(&#8221;/AppName/CSS/PrinterFriendlyStyleSheet.css&#8221;) Print;</span></p>
<p><strong>Discussion:</strong> This solution requires moving our Printer Friendly Style Sheet outside the Theme directory, since Themes don&#8217;t allow us to exclude a Style Sheet folder (see <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder</a> for more details). Once we start moving Style Sheets outside the Themes directory we should probably ask ourselves why we&#8217;re even using Themes, and consider regaining complete control over our CSS by moving all the CSS files outside the Theme directory. At this point we could revert to Externally Linking our Style Sheets where we could define our Media Type attributes. In addition the CSS <a href="http://www.w3.org/TR/REC-CSS1#url">URL function</a> used in this solution confuses many.<br />
<strong></strong></p>
<p><strong>Option 3. </strong>Use the <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.2.3">Style Element</a> to define a Print <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.2.4">Media Type</a>.</p>
<p><strong>An example:</strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">media</span><span>=<span style="color: #0000ff;">&#8220;print&#8221;</span>&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: green;">/*&#8230; your CSS here &#8230;*/</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span>&gt;</p>
<p><strong>Discussion:</strong> This solution doesn&#8217;t work if the <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.2.3">Style Elements</a> are defined in the HTML head (see <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style Sheets with Themes</a> for more details), you can however move the Style Element into the Body of the document, this compromises the HTML validation, but large e-commerce sites like <a href="http://amazon.com/">Amazon</a> and <a href="http://www.yahoo.com/">Yahoo!</a> make heavy use of this method.</p>
<p><strong>Option 4. </strong>Sub class the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlhead_members.aspx">HtmlHead class</a> to enumerate through the child controls and add new Meta attributes to the child controls using the <a href="http://msdn2.microsoft.com/en-US/library/system.web.ui.htmlcontrols.htmllink_properties.aspx">HtmlLink class</a>. See my post titled <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s)</a> for more details.<br />
<strong>Discussion:</strong> This solution requires a fair amount of work and only solves one of the many problems with Themes, pursuing this solution would probably be a case of <a href="http://www.answers.com/topic/can-t-see-the-forest-for-the-trees">not seeing the forest for the trees</a>.</p>
<p><strong>In conclusion;</strong> Themes are a nice addition to ASP.NET, but have some significant design flaws particularly in the way it uses CSS - in this case how printer friendly (print) CSS Media Types are defined. I wouldn&#8217;t recommend using Themes on a complex web applications that make heavy use of CSS or AJAX, but for small projects they may be a nice option.</p>
<p><strong>Related links:</strong></p>
<ul>
<li> <a href="http://alistapart.com/articles/goingtoprint/">CSS Design: Going to Print</a></li>
<li> <a href="http://alistapart.com/articles/boom">Printing a Book with CSS: Boom!</a></li>
<li> <a href="http://www.tufts.edu/webcentral/tutorials/printcss/">A Print CSS Primer</a></li>
<li> <a href="http://webdesign.about.com/cs/css/a/aa042103a.htm">CSS Media Types Create Print-Friendly Pages</a></li>
</ul>
<p><strong>Related posts:</strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">Where it all Falls Apart</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder (Work Around #1)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s) (Work Around #2)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/">Defining the Load Order (Cascades) for CSS (Work Around #3)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style with Themes (Work Around #4)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problems with Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 - Using Internal (Embedded) Style Sheets with Themes (Work Around #4)</title>
		<link>http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/</link>
		<comments>http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 18:44:36 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,c1575144-e460-464d-b993-259ce96135f4.aspx</guid>
		<description><![CDATA[ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on Cascading Stye Sheet (CSS), but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on <a href="http://en.wikipedia.org/wiki/Css">Cascading Stye Sheet (CSS)</a>, but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your application is even developed, instead I suggest sticking with CSS and perhaps using some default Skins that define CSS selectors like classes or IDs.</p>
<p><strong>The Problem / Question:</strong><br />
How can I add Internal (embedded) style sheets (the ones that use the <a href="http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-styleSheet.html#sec_25.1.">Style element)</a> inside the Head tag when using Master Pages and Themes?Â  How can I override (overload) <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.3">External style sheets</a> for local pages or specific Web User Controls?</p>
<p><strong>A Solution / Work Around:</strong></p>
<p>One option is to create an ASP Placeholder (<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">contentplaceholder</span>) in the Master Page&#8217;s Head tag to add the Style element into the Head of your Web Form (.aspx page). However, this solution doesn&#8217;t work well when using Themes, since themes automatically include the External style sheets after the Style element - I demonstrate this and provide an alternative solution later on in this post.</p>
<p><strong>The Caveat / Warnings:</strong><br />
In most current-generation browsers the loading order for Internal style sheets, and External style sheets depend on their position in the Head tag. This behavior seems to go against what the W3C intended.</p>
<blockquote><p><em>Generally speaking we can say that all the styles will &#8220;cascade&#8221; into a new &#8220;virtual&#8221; style sheet by the following rules, where number four has the highest priority:<br />
</em></p>
<ol>
<li> <em>Browser default</em></li>
<li> <em>External style sheet</em></li>
<li> <em>Internal style sheet (inside the &lt;head&gt; tag)</em></li>
<li> <em>Inline style (inside an HTML element)</em></li>
</ol>
<p><em>- Taken from: <a href="http://www.w3schools.com/css/css_intro.asp">http://www.w3schools.com/css/css_intro.asp</a></em></p></blockquote>
<p>As I understand and as the w3schools point out (I can&#8217;t find a reference from the depths of the <a href="http://www.w3.org/Style/CSS/">W3C</a>), Internal style sheets should have a higher priority than External style sheets, unfortunately this isn&#8217;t the reality. Instead External style sheets and Internal style sheets depend on the loading (cascading) order. An Internal style sheet will only override an External style sheet (in current-generation browsers) if the External style sheet is loaded first. This behavior introduces problems when using an ASP Placeholder because ASP.NET automatically includes the Style Sheets (.css) from the active Theme (App_Theme) directories into the Head tag after the ASP Placeholder&#8217;s contents have been loaded.</p>
<p><strong>An example of the problem:</strong></p>
<p><strong>The directory structure:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_4_VS05_SS1.png" alt="" /></p>
<p class="MsoNormal"><strong>The active Master Page: </strong><br />
<span style="background: yellow none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">&lt;%</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">@</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: maroon;">Master</span> <span style="color: red;">Language</span><span style="color: blue;">=&#8221;C#&#8221;</span> <span style="color: red;">EnableTheming</span><span style="color: blue;">=&#8221;true&#8221;</span> <span style="color: red;">AutoEventWireup</span><span style="color: red;">=&#8221;true&#8221;<br />
CodeFile</span><span style="color: blue;">=&#8221;MasterPage.master.cs&#8221;</span> <span style="color: red;">Inherits</span><span style="color: blue;">=&#8221;MasterPage&#8221;</span> <span style="background: yellow none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">%&gt;</span></span></p>
<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;!</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">DOCTYPE</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">html</span> <span style="color: red;">PUBLIC</span> <span style="color: blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color: blue;">&gt;</span><br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">runat</span><span>=&#8221;server&#8221;&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0<span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;</span></span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">contentplaceholder</span> <span style="color: red;">id</span><span style="color: blue;">=&#8221;ContentPlaceHolderHead&#8221;</span> <span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;</span> <span style="color: blue;">/&gt;</span></span></strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
<span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">form</span> <span style="color: red;">id</span><span style="color: blue;">=&#8221;form1&#8243;</span> <span style="color: red;">runat</span><span>=&#8221;server&#8221;&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><strong><span style="color: blue;">&lt;</span><span style="color: maroon;">h1</span><span style="color: blue;">&gt;</span>Hello World!<span style="color: blue;">&lt;/</span><span style="color: maroon;">h1</span></strong><span><strong>&gt;</strong></span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">form</span><span style="color: blue;">&gt;</span><br />
&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><em><br />
Note: the ASP Content Place Holder between the Head tags and &#8220;Hello World!&#8221; between the H1 tags.</em></p>
<p class="MsoNormal"><strong>The default Web Form (.aspx page) providing the Content for the Master Page&#8217;s Content Place Holder:</strong><br />
<span style="background: yellow none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">&lt;%</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">@</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: maroon;">Page</span> <span style="color: red;">Language</span><span style="color: blue;">=&#8221;C#&#8221;</span> <span style="color: red;">Theme</span><span style="color: blue;">=&#8221;Default&#8221;</span> <span style="color: red;">MasterPageFile</span><span style="color: red;">=<span style="color: #0000ff;">&#8220;~/MasterPage.master&#8221;</span><br />
AutoEventWireup</span><span style="color: blue;">=&#8221;true&#8221;</span> <span style="color: red;">CodeFile</span><span style="color: blue;">=&#8221;Default.aspx.cs&#8221;</span> <span style="color: red;">Inherits</span><span style="color: blue;">=&#8221;Default&#8221;</span> <span style="background: yellow none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">%&gt; </span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">Content</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">ID</span><span style="color: blue;">=&#8221;Content1&#8243;</span> <span style="color: red;">ContentPlaceHolderID</span><span style="color: blue;">=&#8221;ContentPlaceHolderHead&#8221;</span> <span style="color: red;">Runat</span><span>=<span style="color: #0000ff;">&#8220;Server&#8221;</span>&gt;</span></span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">style</span> <span style="color: red;">type</span><span>=&#8221;text/css&#8221;&gt;<br />
</span><span style="color: maroon;">H1</span>{<br />
<span> </span><span style="color: red;">color</span>: <span style="color: blue;">red</span>;<br />
<span> </span>}<br />
<span> </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">style</span><span style="color: blue;">&gt;</span></span></strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">asp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">:</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">Content</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><em><br />
Note: the Style element between the ASP Content Place Holder tag - H1 should now be colored red.</em></p>
<p class="MsoNormal"><strong>The contents of StyleSheet.css, the only CSS file in the Active Theme (App_Theme) directory:</strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">H1</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{<br />
<span> </span><strong><span style="color: red;">color</span>: <span style="color: blue;">blue</span>;</strong><br />
}</span><br />
<em>Note: H1 should still be red because Internal style sheets are supposed to have priority over External style sheets.</em><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><strong>The rendered XHTML:</strong><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;!</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">DOCTYPE</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">html</span> <span style="color: red;">PUBLIC</span> <span style="color: blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt; </span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color: blue;">&gt;</span><br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
<span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0<span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span><strong> </strong></span><strong><span style="color: blue;">&lt;</span><span style="color: maroon;">style</span> <span style="color: red;">type</span><span>=&#8221;text/css&#8221;&gt;<br />
</span><span style="color: maroon;">H1</span>{<br />
<span> </span><span style="color: red;">color</span>: <span style="color: blue;">red</span>;<br />
<span> </span>}<br />
<span> </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">style</span></strong><span><strong>&gt;</strong> </span></span></p>
<p><strong><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/StyleSheet.css&#8221;</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span></strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
<span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">form</span> <span style="color: red;">name</span><span style="color: blue;">=&#8221;aspnetForm&#8221;</span> <span style="color: red;">method</span><span style="color: blue;">=&#8221;post&#8221;</span> <span style="color: red;">action</span><span style="color: blue;">=&#8221;Default.aspx&#8221;</span> <span style="color: red;">id</span><span>=&#8221;aspnetForm&#8221;&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">div</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;hidden&#8221;</span> <span style="color: red;">name</span><span style="color: blue;">=&#8221;__VIEWSTATE&#8221;</span> <span style="color: red;">id</span><span style="color: blue;">=&#8221;__VIEWSTATE&#8221;</span> <span style="color: red;">value</span><span style="color: blue;">=&#8221;&#8230;&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;/</span><span style="color: maroon;">div</span><span>&gt;</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span><strong> </strong></span><strong><span style="color: blue;">&lt;</span><span style="color: maroon;">h1</span><span style="color: blue;">&gt;</span>Hello World!<span style="color: blue;">&lt;/</span><span style="color: maroon;">h1</span></strong><span><strong>&gt;</strong></span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">form</span><span style="color: blue;">&gt;</span><br />
&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><em><br />
Note: the position of the External Style Sheet (the Link element) in relation to the Internal Style Sheet (the Style element) - the Internal style definition (</em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong></strong><span style="color: red;">color</span>: <span style="color: blue;">red</span>;</span><em>) precedes the External style definition (</em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: red;">color</span>: <span style="color: blue;">blue</span>;</span><em>). </em></p>
<p><strong>The results in a web browser:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_4_FF_SS1.png" alt="" /><br />
<em>Note: according to the style sheet priorities in the W3C guidelines (see above) &#8220;Hello World!&#8221; should be colored red not blue - the Internal Style should be applied before the External Style; however, this is not the case.</em><br />
<strong>Conclusion;</strong> the ASP Content Place Holder &#8220;Work Around&#8221; doesn&#8217;t work well with Themes since ASP.NET automatically includes all the CSS files in the active Theme directory - this behavior disrupts the loading (cascading) orders. This &#8220;Work Around&#8221; could be useful if you were only using Master Pages or were painfully meticulous with your CSS names and made heavy use of the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#important-rules"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">!important</span></a> style definition.</p>
<p><strong>Another Solution / Another Work Around:</strong><br />
Define the Style element outside the Head tag, directly within the content of your page.<strong> </strong></p>
<p><strong> An example of the Work Around:</strong><br />
<strong>The rendered XHTML:<br />
</strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;!</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">DOCTYPE</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">html</span> <span style="color: red;">PUBLIC</span> <span style="color: blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span><br />
</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color: blue;">&gt;</span><br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
<span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0<span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">style</span> <span style="color: red;">type</span><span>=&#8221;text/css&#8221;&gt;<br />
</span><span style="color: maroon;">H1</span>{<br />
<span> </span><span style="color: red;">color</span>: <span style="color: blue;">red</span>;<br />
<span> </span>}<br />
<span> </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">style</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/StyleSheet.css&#8221;</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span><br />
&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">style</span> <span style="color: red;">type</span><span>=&#8221;text/css&#8221; </span></strong></span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">media</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">=&#8221;screen&#8221;</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><strong><span>&gt;<br />
</span><span style="color: maroon;">H1</span>{<br />
<span> </span><span style="color: red;">color</span>: <span style="color: blue;">green</span>;<br />
<span> </span>}<br />
<span> </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">style</span></strong><span><strong>&gt;</strong></span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">form</span> <span style="color: red;">name</span><span style="color: blue;">=&#8221;aspnetForm&#8221;</span> <span style="color: red;">method</span><span style="color: blue;">=&#8221;post&#8221;</span> <span style="color: red;">action</span><span style="color: blue;">=&#8221;Default.aspx&#8221;</span> <span style="color: red;">id</span><span>=&#8221;aspnetForm&#8221;&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">div</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;hidden&#8221;</span> <span style="color: red;">name</span><span style="color: blue;">=&#8221;__VIEWSTATE&#8221;</span> <span style="color: red;">id</span><span style="color: blue;">=&#8221;__VIEWSTATE&#8221;</span> <span style="color: red;">value</span><span style="color: blue;">=&#8221;&#8230;&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;/</span><span style="color: maroon;">div</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">h1</span><span style="color: blue;">&gt;</span>Hello World!<span style="color: blue;">&lt;/</span><span style="color: maroon;">h1</span><span>&gt;<br />
</span><span style="color: blue;">&lt;/</span><span style="color: maroon;">form</span><span style="color: blue;">&gt;</span><br />
&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">body</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
</span><em>Note: the Style element (</em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: red;">color</span>: <span style="color: blue;">green</span>;</span><em>)inside the Body tag.</em></p>
<p><strong> The results in a web browser:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_4_FF_SS2.png" alt="" /><br />
<em>Note: &#8220;Hello World!&#8221; is green as expected.</em><br />
<strong>The Pros and Cons to this (the Style element outside the Head tag) approach:</strong><br />
<strong>Cons:</strong></p>
<ol>
<li> It&#8217;s not a recommended best practice, but is used by some of the larger sites like <a href="http://amazon.com/">Amazon</a> and <a href="http://www.yahoo.com">Yahoo!</a></li>
<li> It&#8217;s not valid <a href="http://en.wikipedia.org/wiki/XHTML">XHTML</a> (but neither are iframes in <a href="http://www.w3.org/TR/xhtml1/#strict">XHTML Strict</a>)</li>
</ol>
<p><strong>Pros:</strong></p>
<ol>
<li> Can use <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">Microsoft&#8217;s Conditional Comments</a></li>
<li> Can use the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">CSS @Import rule</a></li>
<li> Can use the <a href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule">CSS @Media rule</a></li>
<li> Can use multiple <a href="http://www.w3.org/TR/REC-CSS2/media.html">CSS Media types</a></li>
<li> Can easily use <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.1">Media-dependent cascades</a></li>
<li> Can easily control the CSS load order (<a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.2">inheritance and cascading</a>)</li>
<li> It&#8217;s fairly intuitive and understandable</li>
<li> It&#8217;s compatible with Revision Control Systems</li>
</ol>
<p><strong>Conclusion;</strong> Themes are a nice addition to ASP.NET, but have some significant design flaws particularly in the way it uses CSS. Themes aren&#8217;t recommended for complex web applications that make heavy use of CSS, but for small projects they may be a nice option.</p>
<p><strong>Related posts:</strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">Where it all Falls Apart</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder (Work Around #1)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s) (Work Around #2)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/">Defining the Load Order (Cascades) for CSS (Work Around #3)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/">Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problems with Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 - Defining the Load Order (Cascades) for CSS (Work Around #3)</title>
		<link>http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/</link>
		<comments>http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 19:30:21 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,003772b4-6ef1-4a6c-ba46-f122c787a052.aspx</guid>
		<description><![CDATA[ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on Cascading Stye Sheet (CSS), but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on <a href="http://en.wikipedia.org/wiki/Css">Cascading Stye Sheet (CSS)</a>, but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your application is even developed, instead I suggest sticking with CSS and perhaps using some default Skins that define CSS selectors like classes or IDs.</p>
<p><strong>The Problem / Question:</strong><br />
Is it possible to define the loading order (<a href="http://www.w3.org/TR/REC-CSS2/cascade.html#cascade">cascades</a>) of CSS files while using Themes in ASP.NET 2.0?</p>
<p><strong>The Solutions / Work Arounds:</strong><br />
Order your CSS files alphanumerically - ASP.NET 2.0 parses through the active Theme directory and all sub directories alphanumerically including every CSS file into the HTML head (via an <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.3">external link</a>) of the rendered page.</p>
<p><strong>An example of the problem (when load order isn&#8217;t defined).<br />
</strong><em>Note: both examples use the same CSS files, but use different loading orders.</em></p>
<p><strong>The directory structure and StyleSheets:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_3_VS05_SS1.png" alt="" /></p>
<p class="MsoNormal"><strong>The rendered XHTML:</strong><br />
<span style="font-size: xx-small;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;</span><br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
<span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0 <span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/Controls/<strong>OverloadedUserWebControlStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/Controls/<strong>ReusedUserWebControlStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/<strong>OverloadedStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/<strong>ReusedStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span><br />
&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></span></p>
<p><strong>The results in a web browser:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_3_IE_SS1.png" alt="" /></p>
<p><strong><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;;">An example of the problem (when load order has been defined alphanumerically).</span></strong></p>
<p><strong>The directory structure and StyleSheets:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_3_VS05_SS2.png" alt="" /><br />
<em>Note: the use of alphanumeric delimiters preceding the Style Sheet names.</em></p>
<p class="MsoNormal"><strong>The rendered XHTML:</strong><br />
<span style="font-size: xx-small;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">html</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: red;">xmlns</span><span style="color: blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt; </span><br />
&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;<br />
<span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0 <span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/<strong>aa_ReusedStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/Controls/<strong>01_ReusedUserWebControlStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/Controls/<strong>09_OverloadedUserWebControlStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;<br />
</span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span>=&#8221;App_Themes/Default/<strong>zz_OverloadedStyleSheet.css</strong>&#8220;<br />
</span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span>/&gt;</span><span style="color: blue;"> </span><br />
&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></span><br />
<em>Note: the ordering of the CSS files.</em></p>
<p>The results in a web browser:<br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_3_IE_SS2.png" alt="" /></p>
<p><strong> Comparing the web browser results:</strong><br />
<img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_3_IE_SS1.png" alt="" /> <img src="http://adam.kahtava.com/journal/images/blog/TPWTAS_3_IE_SS2.png" alt="" /><br />
<strong>The Pros and Cons to this approach:</strong></p>
<p><strong>Cons:</strong></p>
<ol>
<li> Being a work around it&#8217;s not intuitive _ a maintenance programmers nightmare - &#8220;I&#8217;m familiar with CSS, but how are the Cascading Style Sheets being loaded??&#8221;</li>
<li> Contributes to a fragile environment - the way ASP.NET parses through the App_Themes directories may change in newer versions of ASP.NET, not to mention changing a filename could have negative side effects on the site&#8217;s design.</li>
</ol>
<p><strong>Pros:</strong></p>
<ol>
<li> Allows a load order to be defined</li>
<li> Compatible with <a href="http://en.wikipedia.org/wiki/Version_control">Revision Control Systems</a></li>
</ol>
<p><strong>In conclusion;</strong> Themes are a nice addition to ASP.NET, but have some significant design flaws particularly in the way it uses CSS. Themes aren&#8217;t recommended for complex web applications that make heavy use of CSS, but for small projects they may be a nice option.</p>
<p><strong>Related posts:</strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">Where it all Falls Apart</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder (Work Around #1)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s) (Work Around #2)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style with Themes (Work Around #4)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/">Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problems with Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 - Defining a Media Type(s) (Work Around #2)</title>
		<link>http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/</link>
		<comments>http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/#comments</comments>
		<pubDate>Sat, 11 Nov 2006 16:34:50 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,63d6c2f3-4cd9-4a7d-ab5a-2796033cb3a1.aspx</guid>
		<description><![CDATA[ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on Cascading Stye Sheet (CSS), but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on <a href="http://en.wikipedia.org/wiki/Css">Cascading Stye Sheet (CSS)</a>, but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your application is even developed, instead I suggest sticking with CSS and perhaps using some default Skins that define CSS classes or IDs.</p>
<p><strong>The Problem / Question:</strong><br />
Is it possible to define CSS Media types (like <span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">media</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">=&#8221;print&#8221;</span>) in the HTML Head tag? ASP.NET 2.0 automatically includes all my CSS files (from the active Theme directory) into the <a href="http://en.wikipedia.org/wiki/HTML">HTML</a> Head tag, but Themes don&#8217;t allow me to specify any <a href="http://www.w3.org/TR/REC-CSS2/media.html">CSS Media types</a>.</p>
<p><strong>The Solutions / Work Arounds:</strong><br />
Sub class the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlhead_members.aspx">HtmlHead class</a> to enumerate through the child controls and add new Meta attributes to the child controls using the <a href="http://msdn2.microsoft.com/en-US/library/system.web.ui.htmlcontrols.htmllink_properties.aspx">HtmlLink class</a>. In order to use multiple Media types you would probably need to use more complex logic and resolve Media types to filenames (i.e. SomeFileName_Print.css could resolve to <span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">media</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">=&#8221;print&#8221;</span>) - for more information on manipulating the HtmlHead class read <a href="http://weblogs.asp.net/pscott/default.aspx">Phil Scott&#8217;s</a> post titled: <a href="http://weblogs.asp.net/pscott/archive/2005/08/30/424039.aspx">Accessing the Html Header in ASP.NET 2.0</a>.</p>
<p><strong>An example of the problem:</strong><br />
The HTML source automatically generated by ASP.NET 2.0 Themes (note the lack of <span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">media</span> attributes):<br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;"> &lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0 <span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/HandHeld.css&#8221;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/Print.css&#8221;</span><br />
<span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/Screen.css&#8221;</span><br />
<span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></p>
<p>My desired HTML source (note the <strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">media</span></strong> attributes in bold):<br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;"> &lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0 <span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/Default.css&#8221;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <strong><span style="color: red;">media</span><span style="color: blue;">=</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong><span style="color: blue;">all</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong></strong> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/HandHeld.css&#8221;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <strong><span style="color: red;">media</span><span style="color: blue;">=</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong><span style="color: blue;">handheld</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong></strong> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/Print.css&#8221;</span> </span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: red;"> type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <strong><span style="color: red;">media</span><span style="color: blue;">=</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong><span style="color: blue;">print</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong></strong> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;"> &lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=&#8221;App_Themes/Default/Screen.css&#8221;</span> </span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: red;"> type</span><span style="color: blue;">=&#8221;text/css&#8221;</span> <span style="color: red;">rel</span><span style="color: blue;">=&#8221;stylesheet&#8221;</span> <strong><span style="color: red;">media</span><span style="color: blue;">=</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong><span style="color: blue;">screen</span></strong></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: blue;">&#8220;</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><strong></strong> <span style="color: blue;">/&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></p>
<p>The Pros and Cons of this approach:<br />
<strong></strong></p>
<p><strong>Cons:</strong></p>
<ol>
<li> Can&#8217;t use <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">Microsoft&#8217;s Conditional Comments</a></li>
<li> Can&#8217;t use the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">CSS @Import rule</a></li>
<li> Can&#8217;t use the <a href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule">CSS @Media rule</a></li>
<li> Can&#8217;t easily use multiple <a href="http://www.w3.org/TR/REC-CSS2/media.html">CSS Media types</a></li>
<li> Can&#8217;t easily control <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.3.1">CSS preferred and alternate style sheets</a></li>
<li> Can&#8217;t easily control the CSS load order (<a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.2">inheritance and cascading</a>)</li>
<li> Contributes to a fragile environment</li>
<li> Not intuitive _ a maintenance programmers nightmare - &#8220;I know CSS, but Where are the Media types defined and How are they controlled?&#8221;</li>
</ol>
<p><strong>Pros:</strong></p>
<ol>
<li> Can define a single <a href="http://www.w3.org/TR/REC-CSS2/media.html">Media type</a> for all .css files relatively easy</li>
<li> Could define multiple Media types - with more complex logic dependant on .css file naming</li>
<li> Could control CSS preferred and alternate style sheets - with more complex logic dependant on .css file naming</li>
<li> Compatible with <a href="http://en.wikipedia.org/wiki/Version_control">Revision Control Systems</a> (<a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System">CVS</a>, <a href="http://en.wikipedia.org/wiki/Subversion">Subversion</a>, <a href="http://en.wikipedia.org/wiki/Visual_Source_Safe">Visual Source Safe</a>, and so on)</li>
</ol>
<p><strong>In conclusion;</strong> CSS will continue to be the industry design standard - it has been the standard for well over 10 years. CSS is far more powerful than Themes and Skins, I suggest sticking with CSS and perhaps using some default Skins that define CSS classes or IDs.</p>
<p><strong>Related posts:</strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">Where it all Falls Apart</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder (Work Around #1)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/">Defining the Load Order (Cascades) for CSS (Work Around #3)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style with Themes (Work Around #4)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/">Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problems with Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 - Excluding a CSS folder (Work Around #1)</title>
		<link>http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/</link>
		<comments>http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/#comments</comments>
		<pubDate>Fri, 10 Nov 2006 00:32:47 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,7e992478-da0f-4ce4-bb43-3a0b58f6f3ad.aspx</guid>
		<description><![CDATA[ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on Cascading Stye Sheet (CSS), but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0&#8217;s Themes and Skins have a number of design flaws - Themes and Skins depend almost entirely on Cascading Stye Sheet (CSS), but don&#8217;t fully support CSS - I&#8217;ve listed some &#8220;Work Arounds&#8221; for a couple design flaws. I don&#8217;t recommend any of these &#8220;Work Arounds&#8221; since they contribute to software entropy before your application is even developed, instead I suggest sticking with CSS and perhaps using some default Skins that define CSS classes or IDs.</p>
<p><strong>The Problem / Question: </strong><br />
How can I exclude a subdirectory (sub folder) containing <a href="http://en.wikipedia.org/wiki/Css">Cascading Style Sheets (CSS)</a> in a Theme (App_Theme) directory? ASP.NET 2.0 automatically includes all CSS files (.css) from the active Theme directory and sub directories into the rendered HTML page, but doesn&#8217;t allow me to exclude a folder of CSS files or a single CSS file.</p>
<p><strong>The Solutions / Work Arounds:</strong></p>
<ol>
<li> Create your CSS directory outside the App_Theme directory then map a Virtual Directory inside your Theme directory.</li>
<li> Add a custom VirtualPathProvider to ignore the non-root level CSS files in sub directoriesÂ  - See <a href="http://blogs.msdn.com/davidebb/default.aspx">David Ebbo&#8217;s</a> article titled: <a href="http://blogs.msdn.com/davidebb/archive/2005/11/27/overriding-asp-net-combine-behavior-using-a-virtualpathprovider.aspx">Overriding ASP.NET combine behavior using a VirtualPathProvider</a>.</li>
</ol>
<p>These &#8220;Work Arounds&#8221; are useful if you want to do something like this (note: Default.css is sitting in the root of the active Theme directory):</p>
<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">/* Default.css */</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">@Import</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> &#8220;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">StyleSheets/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Common.css &#8220;;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">@Import</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> &#8220;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">StyleSheets/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Masterpage.css&#8221;;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> &lt;!&#8211;[if IE]&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">@Import</span> &#8220;StyleSheets/FixInternetExplorer_Quirks.css&#8221;;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&lt;![endif]&#8211;&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&lt;!&#8211;[if IE 7]&gt;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">@Import</span> &#8220;StyleSheets/FixInternetExplorer7Quirks.css&#8221;;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&lt;![endif]&#8211;&gt;</span></p>
<p>Or if you wanted to use an Embedded CSS Statement like this:</p>
<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/css&#8221;&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&lt;!<span style="color: maroon;">&#8211;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">@Import</span> &#8220;StyleSheets/HideNavigation.css&#8221;;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span> </span><span style="color: blue;">@Import</span> &#8220;StyleSheets/HideSearchBars.css&#8221;;</span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&#8211;<span style="color: maroon;">&gt;</span></span><br />
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">style</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></p>
<p>The Pros and Cons of this approach:</p>
<p><strong>Cons</strong>:</p>
<ol>
<li> Can&#8217;t really define <a href="http://www.w3.org/TR/REC-CSS2/media.html">CSS media types</a>, but we can now use the <a href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule">CSS @Media rule</a></li>
<li> Can&#8217;t control <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.3.1">CSS preferred and alternate style sheets</a></li>
<li> Doesn&#8217;t scale well</li>
<li> Contributes to a fragile development environment</li>
<li> Not very compatible with <a href="http://en.wikipedia.org/wiki/Version_control">Revision Control Systems</a> (<a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System">CVS</a>, <a href="http://en.wikipedia.org/wiki/Subversion">Subversion</a>, <a href="http://en.wikipedia.org/wiki/Visual_Source_Safe">Visual Source Safe</a>, and so on)</li>
<li> Not intuitive _ a maintenance programmer&#8217;s nightmare, &#8220;I know CSS, but Where is the CSS folder?&#8221; or &#8220;I know CSS, but Why and How are some CSS folders excluded?</li>
</ol>
<p><strong>Pros</strong>:</p>
<ol>
<li> Can control the load order (<a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.2">inheritance and cascading</a>) through the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">CSS @Import rule</a></li>
<li> Can exclude a folder containing CSS files</li>
<li> Can use the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">CSS @Import rule</a></li>
<li> Can use the <a href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule">CSS @Media rule</a></li>
<li> Can use <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">Microsoft&#8217;s conditional comments</a></li>
</ol>
<p><strong><br />
In conclusion;</strong> CSS will continue to be the industry design standard - it has been the standard for well over 10 years. CSS is far more powerful than Themes and Skins, I suggest sticking with CSS and perhaps using some default Skins that define CSS classes or IDs.</p>
<p><strong>Related posts: </strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/">Where it all Falls Apart</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s) (Work Around #2)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/">Defining the Load Order (Cascades) for CSS (Work Around #3)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style with Themes (Work Around #4)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/">Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Where it all Falls Apart</title>
		<link>http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/</link>
		<comments>http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/#comments</comments>
		<pubDate>Thu, 09 Nov 2006 01:11:28 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,4df765e2-b408-471e-9999-652cd804b683.aspx</guid>
		<description><![CDATA[Themes and Skins are a promising addition to ASP.NET 2.0, but too immature for large web projects.
The problem with Themes and Skins begins with the way Cascading Style Sheets (CSS) are automatically included into the rendered page. Through compilation logic, ASP.NET 2.0 parses through the directory and sub directories of the active Theme. ASP.NET 2.0 [...]]]></description>
			<content:encoded><![CDATA[<p>Themes and Skins are a promising addition to ASP.NET 2.0, but too immature for large web projects.</p>
<p>The problem with Themes and Skins begins with the way <a href="http://en.wikipedia.org/wiki/Css">Cascading Style Sheets (CSS)</a> are automatically included into the rendered page. Through compilation logic, ASP.NET 2.0 parses through the directory and sub directories of the active Theme. ASP.NET 2.0 automatically includes an external CSS file reference into the HTML Head tag of the rendered page for every CSS file encountered.</p>
<p>Here&#8217;s an example for a better understanding.</p>
<p>My directory structure:<br />
<img src="http://adam.kahtava.com/journal/Images/blog/TheProblemsWithThemesAndSkins.png" alt="" /></p>
<p>The output generated by Themes from the preceding directory structure:</p>
<pre><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt; </span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>The Problems With Themes and Skins in ASP.NET 2.0 <span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/HandHeld.css"</span>
   <span style="color: red;">type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span>/&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/Print.css" </span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span>/&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/Screen.css" </span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span>/&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/StyleSheets/FixInternetExplorer7Quirks.css"</span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span>/&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/StyleSheets/FixInternetExplorerQuirks.css" </span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span>/&gt; </span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/StyleSheets/HideAdvertisments.css" </span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: blue;">/&gt;</span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/StyleSheets/HideBorders.css" </span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: blue;">/&gt;</span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"><span> </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/StyleSheets/HideMenus.css" </span>
<span style="color: red;">   type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: blue;">/&gt;</span></span>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></pre>
<p>As you can see, the external CSS file references are automatically included in the rendered page - the load order of CSS files seems to depend on the directory and CSS file name. In this example the root directory is parsed alphabetically then the sub directory is parsed alphabetically.</p>
<p>It&#8217;s neat how ASP.NET 2.0 automatically includes .css files, but this behavior severely limits the use of CSS (see the list below), and encourages developers / designers to create many .css files which introduces new problems - Internet Explorer has a 30 style sheet limitation, see article <a href="http://support.microsoft.com/kb/q262161">Q262161</a>.</p>
<p><strong>Problems:</strong></p>
<ul>
<li> As the name implies Cascading Style Sheets (CSS) depend on the order in which files are loaded (cascades), in addition to other rules like the CSS @import and CSS @Media rule. By automatically loading all .css files into the header, Themes prevent cascades and loading order from being defined.</li>
<li> The automatic inclusion of .css files prevents the use of Microsoft&#8217;s Conditional Comments.</li>
<li> The automatic inclusion of CSS files omits the CSS Media type.</li>
</ul>
<p><strong>A rough list of CSS features compromised by Themes in ASP.NET 2.0:</strong></p>
<ol>
<li> <a href="http://www.w3.org/TR/REC-CSS2/media.html">CSS media types</a></li>
<li> <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import">The CSS @Import rule</a></li>
<li> <a href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule">The CSS @Media rule</a></li>
<li> <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.3.1">Preferred and alternate style sheets</a></li>
<li> <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.1">Media-dependent cascades</a></li>
<li> <a href="http://www.w3.org/TR/html4/present/styles.html#h-14.4.2">Inheritance and cascading</a></li>
<li> <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">The use of Microsoft&#8217;s Conditional Comments</a></li>
</ol>
<p>An example of when these compromised features are useful:</p>
<pre><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-family: 'Courier New'; color: #0000ff; font-size: x-small;">&gt;</span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span>  </span><span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span><span style="color: #0000ff;">The Problems With Themes and Skins in ASP.NET 2.0 </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span>&gt;</span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span>  </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/HandHeld.css" </span>
<span style="color: red;">    type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="font-size: x-small;"><strong><span style="color: red;">media</span><span style="color: blue;">="handheld"</span></strong></span> <span>/&gt;</span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span>  </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/Print.css" </span>
<span style="color: red;">    type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="font-size: x-small;"><strong><span style="color: red;">media</span><span style="color: blue;">="print"</span></strong></span> <span>/&gt;</span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span>  </span><span style="color: blue;">&lt;</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="App_Themes/Default/Screen.css" </span>
<span style="color: red;">    type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="font-size: x-small;"><strong><span style="color: red;">media</span><span style="color: blue;">="screen"</span></strong></span> <span>/&gt;</span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span><span style="color: #008000;">  </span></span><span style="font-size: x-small;"><strong><span style="color: #008000;"><span>&lt;!--[IF IE]&gt;</span></span></strong></span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: #008000;"><span>    </span>&lt;link href="App_Themes/Default/StyleSheets/FixInternetExplorerQuirks.css" </span></span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;">
<span style="color: #008000;">      type="text/css" rel="stylesheet" <span style="font-size: x-small;"><strong>media="all"</strong></span> /&gt;</span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: #008000;"><span>  </span><span style="font-size: x-small;"><strong>&lt;![endif]--&gt;</strong></span></span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: #008000;"><span>  </span><span style="font-size: x-small;"><strong><span>&lt;!--[IF IE 7]&gt;</span></strong></span></span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: #008000;"><span>    </span>&lt;link href="App_Themes/Default/StyleSheets/FixInternetExplorer7Quirks.css" </span></span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;">
<span style="color: #008000;">      type="text/css" rel="stylesheet" <span style="font-size: x-small;"><strong>media="all"</strong></span> /&gt;</span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><span style="color: #008000;"><span>  </span><span style="font-size: x-small;"><strong>&lt;![endif]--&gt;</strong></span></span></span>
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: maroon;">head</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span></pre>
<p>The contents of Print.css or HandHeld.css would generally look something like this:<br />
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: green;">/* Contents of Print.css or HandHeld.css*/ </span></p>
<p><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="font-size: x-small;"><strong>@Import</strong></span></span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: #000000;">&#8220;App_Themes/Default/StyleSheets/HideAdvertisments.css&#8221;;</span></span><br />
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><strong><span style="font-size: x-small;">@Import</span></strong></span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"> <span style="color: #000000;">&#8220;App_Themes/Default/StyleSheets/HideBorders.css&#8221;;</span></span><br />
<span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: blue;"><strong><span style="font-size: x-small;">@Import</span></strong></span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;;"> &#8220;App_Themes/Default/StyleSheets/HideMenus.css&#8221;;</span></p>
<p><strong>In conclusion</strong>; Themes have a number of design flaws which limit a significant portion of CSS&#8217;s mature feature set. Themes are OK for small web applications, but not recommended for large / complex applications. While there are &#8220;work arounds&#8221; for some of the issues on my list, implementing each &#8220;work around&#8221; contributes to software entropy before your application is even developed. Since Skins and Themes are really based around CSS you might be better off sticking with CSS and a single default ASP.NET 2.0 Skin in which you define some default CSS classes or ID elements for some basic ASP.NET server controls.</p>
<p><strong>Related notes:</strong></p>
<p><strong></strong><strong>Rick Strahl came to a similar conclusion:</strong></p>
<blockquote><p>theming is nice but really most of that can be accomplished with CSS and what Themes offers beyond that is really not that critical. [...] As it stands I don&#8217;t really see how I can utilize Themes in my apps in a meaningful way. - <a href="http://west-wind.com/WebLog/posts/4803.aspx">Playing around with ASP.NET Themes</a></p></blockquote>
<p><strong><span>Scott Allen makes a great point:</span></strong></p>
<blockquote><p>Web designers will be more comfortable with css files. If you put the design of your site into the hands of professionals than you should be asking them to use css wherever possible. - <a href="http://www.odetocode.com/Articles/423.aspx">Themes In ASP.NET 2.0</a></p></blockquote>
<p><strong>Richard P </strong><strong>makes a related comment:</strong></p>
<blockquote><p>there are so many flaws in Themes and how they use CSS I dont know where to begin! [...] The concept of CSS and the web skin has been around for some years, and we have been building great solutions despite Visual Studio and ASP.NET. - <a href="http://discuss.joelonsoftware.com/default.asp?dotnet.12.451397.4">Themes and Skins Flawed in ASP.NET 2.0</a></p></blockquote>
<p>Learn more about Themes and Skins here: <a href="http://msdn.microsoft.com/msdnmag/issues/05/11/CuttingEdge/default.aspx">A Quick Tour of Themes in ASP.NET 2.0</a>.</p>
<p><strong>Related posts:</strong></p>
<ul>
<li> <a href="http://adam.kahtava.com/journal/2006/11/09/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-excluding-a-css-folder-work-around-1/">Excluding a CSS folder (Work Around #1)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2006/11/11/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-a-media-types-work-around-2/">Defining a Media Type(s) (Work Around #2)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/03/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-defining-the-load-order-cascades-for-css-work-around-3/">Defining the Load Order (Cascades) for CSS (Work Around #3)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/05/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-using-internal-embedded-style-sheets-with-themes-work-around-4/">Using Internal (Embedded) Style with Themes (Work Around #4)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/02/25/the-problems-with-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-creating-printer-friendly-pages-defining-a-css-print-media-type-with-css-while-using-themes-work-around-5/">Creating Printer Friendly Pages (defining a CSS Print Media Type) with CSS While Using Themes (Work Around #5)</a></li>
<li> <a href="http://adam.kahtava.com/journal/2007/04/02/a-resolution-to-the-problems-with-themes-skins-and-cascading-style-sheets-css-putting-the-cascades-back-into-aspnet-20-themes-taking-control-over-css-cascades-load-order-media-types-and-o/">A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2006/11/08/the-problems-with-themes-skins-and-cascading-style-sheets-css-where-it-all-falls-apart/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Reflection on Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 (Part 2)</title>
		<link>http://adam.kahtava.com/journal/2006/10/30/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-part-2/</link>
		<comments>http://adam.kahtava.com/journal/2006/10/30/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-part-2/#comments</comments>
		<pubDate>Tue, 31 Oct 2006 00:26:43 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,69f6fc25-9820-4abf-a930-b119401b1dc7.aspx</guid>
		<description><![CDATA[Themes and Skins depend on Cascading Style Sheets (CSS) and HTML / XHTML, but Themes and Skins don&#8217;t fully support CSS - now that&#8217;s a paradox.

HTML, XHTML, XML, and other related Markup Languages can all be manipulated through CSS - ASP.NET generates most of these languages. If your not yet familair with ASP.NET 2.0 Themes [...]]]></description>
			<content:encoded><![CDATA[<p>Themes and Skins depend on <a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets">Cascading Style Sheets (CSS)</a> and <a href="http://en.wikipedia.org/wiki/Html">HTML</a> / <a href="http://en.wikipedia.org/wiki/Xhtml">XHTML</a>, but Themes and Skins don&#8217;t fully support CSS - now that&#8217;s a paradox.</p>
<div><img class="aligncenter" src="http://adam.kahtava.com/journal/images/blog/ASP.NET.Skins.Themes.CSSa.png" alt="" width="361" height="200" /></div>
<p>HTML, XHTML, <a href="http://en.wikipedia.org/wiki/Xml">XML</a>, and other related Markup Languages can all be manipulated through CSS - ASP.NET generates most of these languages. If your not yet familair with ASP.NET 2.0 Themes and Skins: <strong>Skins</strong> give developers and designers a little more precision to manipulate server side controls like <a href="http://samples.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/VB/datagrid5.aspx">datagrids</a>, and <a href="http://samples.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/Calendar/VB/Calendar4.aspx">calendars</a>, but Skins fundamentally depend on CSS. <strong>Themes</strong> allow us to group our Skins, CSS files, graphics / images, and so on into logical groups or directories, but Themes really depend on CSS through Skins and CSS (.css) file references.</p>
<p><strong>Both ASP.NET Themes and Skins are directly dependent on Cascading Style Sheets (CSS)</strong>. However; Themes and Skins prohibit a good deal of CSS&#8217;s functionality - I&#8217;ll discuss this is my next post. CSS has been with us for over a decade, it&#8217;s a pretty powerful display mechanism for web applications. CSS can manipulate HTML, XHTML, XML, SVG, XUL and other common Markup Languages.</p>
<p>I&#8217;ve come up with a number Theme and Skin related questions <span style="text-decoration: line-through;">that I have yet to answer</span>.</p>
<p><strong>Questions</strong>:</p>
<p><strong>If Themes and Skins rely on CSS why not just use CSS?</strong><br />
<strong>Answer:</strong> Default Skins are good, they provide hooks (class and ID selectors) for defining CSS. Themes are OK they let us logically group images and design related files, but fall short in a number of areas and are not recommended for large web applications.Â </p>
<p><strong>If it&#8217;s possible to accomplish all that Skins and Themes offers through CSS why should I make the switch?</strong><br />
<strong>Answer:</strong> Skins can make life easier for your web designers, when used to hook into CSS classes and ID selectors.</p>
<p><strong>CSS is a mature, robust language, it&#8217;s been around for over 10 years so more designers / developers are familiar with it, why should I switch to a a technology that is unfamiliar to most of the people that will be maintaining the application?</strong><br />
<strong>Answer:</strong> It&#8217;s not a clear case of CSS vs Themes since you really can&#8217;t have Themes without CSS. If used properly Themes can augment CSS.</p>
<p><strong>Are Themes and Skins really scalable for a large enterprise level web application?</strong><br />
<strong>Answer:</strong> Not really, having a seperate server or <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network">Content Delivery Network</a> for site resources like images, stylesheets, etc&#8230; is probably the best approach. Themes and Skins do prove uesful for small web applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2006/10/30/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-part-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Reflection on Themes, Skins, and Cascading Style Sheets (CSS) in ASP.NET 2.0 (Part 1)</title>
		<link>http://adam.kahtava.com/journal/2006/10/29/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-part-1/</link>
		<comments>http://adam.kahtava.com/journal/2006/10/29/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-part-1/#comments</comments>
		<pubDate>Sun, 29 Oct 2006 16:06:18 +0000</pubDate>
		<dc:creator>Adam Kahtava</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Firefox]]></category>

		<category><![CDATA[Themes and Skins]]></category>

		<guid isPermaLink="false">http://adam.kahtava.com/journal/PermaLink,guid,7febbbfc-c506-45ad-817d-af62ed1645be.aspx</guid>
		<description><![CDATA[While Themes and Skins are new to ASP.NET 2.0, the underlying concepts have been around for a long time. For those unfamiliar with Themes and Skins, skins give web designers greater flexibility to manipulating ASP.NET server side controls (calendars, datagrids, etc&#8230;) through Styles / Cascading Style Sheets (CSS). Themes logically group the design tier of [...]]]></description>
			<content:encoded><![CDATA[<p>While Themes and Skins are new to ASP.NET 2.0, the underlying concepts have been around for a long time. For those unfamiliar with Themes and Skins, skins give web designers greater flexibility to manipulating ASP.NET server side controls (calendars, datagrids, etc&#8230;) through Styles / Cascading Style Sheets (CSS). Themes logically group the design tier of an application into a common folder or directory (a Theme folder(s)), giving developers the ability to programmatically change (swap), or expose these Themes to the user.</p>
<p>Learn more: <a href="http://msdn2.microsoft.com/en-us/library/ykzx33wh.aspx">ASP.NET Themes and Skins Overview</a>.<br />
See a live example here: <a href="http://www.dotnettreats.com/SampleThemes/Default.aspx">ASP.NET 2.0 Colorful Web Site Starter Kit</a>.</p>
<p>The concept of interchanging layout and changing design styles (Themes) has been around for quite some time. The <a href="http://www.w3.org/TR/html401/present/">W3C Recommendation for Style Sheets in HTML documents</a> outlines the &#8220;<a href="http://www.w3.org/TR/html401/present/styles.html#h-14.3.1">alternate stylesheet</a>&#8221; that should be interchanged through the browsers menu; unfortunately Internet Explorer (IE) fails to support this method.</p>
<p>An example: changing style sheets with a Mozilla based browser (<a href="http://www.mozilla.com/en-US/firefox/">Firefox</a>).</p>
<div><img src="http://adam.kahtava.com/journal/images/blog/damowmow.com.bubbles.png" alt="" /><br />
<img src="http://adam.kahtava.com/journal/images/blog/damowmow.com.modern.png" alt="" /></div>
<p>See the live example (if you&#8217;re not using IE) at: <a href="http://www.damowmow.com/indexes/multiple.html">www.damowmow.com</a>.</p>
<p>Other methods for changing design layouts (Themes) range from Client Side Scripts (JavaScript) to Server Side Scripts (ASP, PHP, ASP.NET, and so on).</p>
<p>Learn more about style interchanging scripts and more here: <a href="http://css-discuss.incutio.com/?page=StyleSwitching">Style Switching - css-discuss</a>.</p>
<p>Themes and Skins are a welcome addition to ASP.NET 2.0, they offer a simple solution for grouping design specific files, and a nice way to programmatically change these Themes. However; this simplistic approach significantly hampers the power of Cascading Style Sheets _ I&#8217;ll discuss my difficulties / problems in subsequent posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kahtava.com/journal/2006/10/29/a-reflection-on-themes-skins-and-cascading-style-sheets-css-in-aspnet-20-part-1/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
