W
wh
This is more a question of style really, nothing too technical - honest.
My question is what is the preferred way of defining the styles of elements
in an asp.net page?
Supposing I have several *Web* controls (i.e. <asp:label> elements) that I
want to apply a formatting style to. The first method would be to select all
controls in page design view then set the appearance properties in the
properties window. The other method would be to set the CssClass property of
each control then create a new css class in a stylesheet and attach this to
the page.
Personally, I tend to stick with the second method though I was wondering
how much we should know about the underlying html that is generated.
Supposing I have an <asp:label> element. This is rendered as a <SPAN>
element, so in my stylesheet I have the following rule:
SPAN.MyLabel
{
/* define style here */
}
May we always assume that <asp:label> elements get rendered as <span>
elements. I know an alternative would be to not supply the SPAN element
declaration in the css rule and just have:
.MyLabel
{
}
but I prefer to supply as much information as possible to the browser that
reads the stylesheet.
Wayne.
My question is what is the preferred way of defining the styles of elements
in an asp.net page?
Supposing I have several *Web* controls (i.e. <asp:label> elements) that I
want to apply a formatting style to. The first method would be to select all
controls in page design view then set the appearance properties in the
properties window. The other method would be to set the CssClass property of
each control then create a new css class in a stylesheet and attach this to
the page.
Personally, I tend to stick with the second method though I was wondering
how much we should know about the underlying html that is generated.
Supposing I have an <asp:label> element. This is rendered as a <SPAN>
element, so in my stylesheet I have the following rule:
SPAN.MyLabel
{
/* define style here */
}
May we always assume that <asp:label> elements get rendered as <span>
elements. I know an alternative would be to not supply the SPAN element
declaration in the css rule and just have:
.MyLabel
{
}
but I prefer to supply as much information as possible to the browser that
reads the stylesheet.
Wayne.