Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

css question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith G Hicks - 18 Mar 2008 23:35 GMT
asp.net 2.0

I am just learning css. I created a css file for an aspx page. On the page I
have several ASP:Label controls. I want them all bold. So I did this in my
css file:

label
{
   font-weight:bold;
}

it did nothing to the page when I ran it.

I added a cssclass="myclass" to one of the labels and then did this in the
css file:

.myclass
{
   font-weight:bold;
}

that worked fine.

Do I have to set a cssclass in each control's markup in order to do this or
is there a way without doing that?

Thanks,

Keith
Segundo Serrano - 18 Mar 2008 23:52 GMT
Hello,

span
{
   font-weight:bold;
}

Regards,

S.

--------------------------------------------------------------------------------

 asp.net 2.0

 I am just learning css. I created a css file for an aspx page. On the page I
 have several ASP:Label controls. I want them all bold. So I did this in my
 css file:

 label
 {
     font-weight:bold;
 }

 it did nothing to the page when I ran it.

 I added a cssclass="myclass" to one of the labels and then did this in the
 css file:

 .myclass
 {
     font-weight:bold;
 }

 that worked fine.

 Do I have to set a cssclass in each control's markup in order to do this or
 is there a way without doing that?

 Thanks,

 Keith
Dathan - 19 Mar 2008 00:01 GMT
> asp.net 2.0
>
[quoted text clipped - 27 lines]
>
> Keith

Hi,

The ASP:Label control renders an output of a SPAN (could be a DIV)
therefore in you CSS use that element as your selector, i.e.:

span{
Font-weight: bold;
}

This will make every span on your page bold. If you want to limit the
effect only to a section, use a contextual selector by wrapping the
ASP:Label tags in an container element such as a div and giving it a
class (an id will work), i.e.:

<div class="myLabels">
< ASP:Label />
< ASP:Label />
< ASP:Label />
</div>

Then in your CSS do this:

.myLabels span { ...}

However, you could just do this: <asp:Label Font-Bold="true"></
asp:Label>

BTW, It's a best practice to use semantically descriptive code, the
<strong> tag is consider such. So it's best to make text bold using
that and not css. (same goes with the <em> for italics.)
Anthony Jones - 19 Mar 2008 10:21 GMT
> > asp.net 2.0

> BTW, It's a best practice to use semantically descriptive code, the
> <strong> tag is consider such. So it's best to make text bold using
> that and not css. (same goes with the <em> for italics.)

I don't think that is best practice in the case of ASP.NET.   The ASP.NET
model attempts to encapsulate the details of the actual HTML tags used to
generate a rendering of its content.  Additionally ASP.NET attempts to give
developers a visual designer so that the page looks as intented.  The whole
point of tags such as <strong> is that they do not defined exactly how
something marked as strong should be visually rendered.

Also the general direction of CSS is to remove tags like <strong> which
direct the appearance of a page.  This is to open the way to tags which
define structure not appearance and even true semantic meaning.  For example
CSS can be applied to XML full of tags that have meaning such as
<name><first>Fred</first><last>Bloggs</last></name>.
Its the CSS which would define whether the name is displayed in-line bold
with a red foreground.

Signature

Anthony Jones - MVP ASP/ASP.NET

Dathan - 19 Mar 2008 18:14 GMT
> > > asp.net 2.0
>
[quoted text clipped - 19 lines]
> --
> Anthony Jones - MVP ASP/ASP.NET

Yes, with ASP.NET controls you have to deal with the output it
renders, and often it's not very nice, that's why people have come
along and developed ways of modifying the output such as CSS Friendly
Control Adapters (www.asp.net/cssadapters/). As for the practice of
separation of presentation, content and behavior, it's still best to
wrap text using a semantically descriptive tag then just a span or
div. For example:

This sentence make a <strong>strong</strong> statement.

Using <strong> is better then using a <span> or a tag with less
semantic meaning.
Anthony Jones - 20 Mar 2008 10:30 GMT
> > "Dathan" <Datha...@gmail.com> wrote in message

news:047705a0-eb31-4e75-9b64-187db6e2ed24@i12g2000prf.googlegroups.com...

> > > > asp.net 2.0
> >
[quoted text clipped - 32 lines]
> Using <strong> is better then using a <span> or a tag with less
> semantic meaning.

I guess its a case of the semantics of semantics ;)

I don't think <strong> has any true semantic meaning.  This in fact has more
semantic meaning:-

<span class="postcode">NG2 2AA</span>

This is even better (but isn't html any more)

<postcode>NG2 2AA</postcode>

In both cases the CSS would determine whether the content should be 'strong'
and exactly what that would mean visually.

The direction of CSS is to be able to apply presentation for structures that
have much deeper semantic meaning than HTML.  Existing HTML 'semantics' such
as <strong> apply to presentation but since CSS is designed to handle that
there is an overlap of responsibilities.  Is CSS responsible for
presentation or the definition of HTML tags?

Signature

Anthony Jones - MVP ASP/ASP.NET

Dathan - 20 Mar 2008 18:45 GMT
> > > "Dathan" <Datha...@gmail.com> wrote in message
>
[quoted text clipped - 65 lines]
> --
> Anthony Jones - MVP ASP/ASP.NET

Yes, both methods work. Using selectors to give semantic meaning was
coined by microformats.org. Keep in mind, element styles depend on a
browser's default stylesheet located deep in the file system, this is
why CSS reset and base styles are an important part of a CSS
framework. So to answer your question, any code that describes its
content is good semantics, but the extent of precision is up to the
developer.
Keith G Hicks - 19 Mar 2008 20:56 GMT
Could someone please explain to me how the web community has redefined the
word "semantic?" The phrase "semantic code" really makes no sense at all
based on the traditional definition of the word. I keep seeing it used over
and over as I learn more about how to create web apps but I'm afraid I'm not
picking up how you all are using it. If you look up "semantic" in the
dictionary, you'll see that this new use does not fit at all. You can say
things like "I'm studying the semantics of this sentence" or "The semantics
of these words is not clear to me" but to say "this sentence is semantic"
makes no sense at all. Please fill me in. I'm a bit in the dark on this one.

Thanks,

Keith
Dathan - 19 Mar 2008 22:24 GMT
> Could someone please explain to me how the web community has redefined the
> word "semantic?" The phrase "semantic code" really makes no sense at all
[quoted text clipped - 9 lines]
>
> Keith

Semantics is the meaning of a word, so using semantic html code means
to use tags that provides meaning to the content it contains. For
example,

<address>235 N-D 45</address>

A computer process can now interpret that gibberish as being an
address.

Make sense? Simply doing a search for "what is semantically correct
html code?" will get you all the answers you need.
Keith G Hicks - 19 Mar 2008 06:36 GMT
Thanks for the info.

Keith

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.