css question

S

Segundo Serrano

Hello,

span
{
font-weight:bold;
}

Regards,

S.


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

"Keith G Hicks" <[email protected]> escribió en el mensaje 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
 
D

Dathan

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

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.)
 
K

Keith G Hicks

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
 
A

Anthony Jones

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

Dathan

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.

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

Keith G Hicks

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
 
D

Dathan

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

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

Anthony Jones

Dathan said:
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.

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?
 
D

Dathan

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?

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.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top