Attaching CSS classes to web controls

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.
 
C

clintonG

I think it should be evident that a label will always be rendered
as a span element as a label is not a container nor a collection
of objects.


--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top