title: How to style an asp.net menu with CSS
body: <p>I'm in the process of styling an asp.net menu and I'm trying to understand the meaning of the StaticSelectedStyle-CssClass and StaticHoverStyle-CssClass parameters.</p>
  
  <p>My understanding is that the styles defined with these parameters are applied as CSS classes to the relevant elements, whenever needed. So I created my menu as follows:</p>
  
  <pre><code>&lt;asp:Menu ID="NavigationMenu" DataSourceID="NavigationSiteMapDataSource" 
          StaticMenuStyle-CssClass="StaticMenuStyle"
          StaticMenuItemStyle-CssClass="StaticMenuItemStyle"
          StaticSelectedStyle-CssClass="StaticSelectedStyle"
          StaticHoverStyle-CssClass="StaticHoverStyle"
          Orientation="Horizontal" 
          MaximumDynamicDisplayLevels="0" 
          runat="server"&gt;
  &lt;/asp:Menu&gt;
  </code></pre>
  
  <p>It works for StaticMenuStyle-CssClass and StaticMenuStyle-CssClass (the classes are applied to the relevant elements), but StaticSelectedStyle-CssClass and StaticHoverStyle-CssClass are not applied, regardless of the selected or hover status of an element.</p>
  
  <p>What am I supposed to do to make this work?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: Sorry I should have mentioned that this is .NET 4. Here is the generated HTML:</p>
  
  <pre><code>&lt;div id="NavigationMenu"&gt;
   &lt;ul class="level1 StaticMenuStyle"&gt;
    &lt;li&gt;&lt;a class="level1 StaticMenuItemStyle selected" href="/Link.aspx"&gt;Link&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So as you can see, StaticMenuStyle and StaticMenuItemStyle are applied, but not StaticSelectedStyle-CssClass or StaticHoverStyle-CssClass. Not sure why. I know I can use selected but isn't the expected behavior that StaticSelectedStyle-CssClass be applied??? By using selected I make assumptions as to what .NET does behind the scenes and that's not right.</p>