can I use css to change font in one cell to bold?

  • Thread starter Thread starter Catherine Jo Morgan
  • Start date Start date
C

Catherine Jo Morgan

I can set up a class in css to specify that the font be bold, correct? Can I
specify then in the page that everything in one table cell is in that class?
 
you sure can. it'd look like this:
<td class="your class">
then anything in the cell will take the attributes you specified.
 
chris leeds said:
you sure can. it'd look like this:
<td class="your class">
then anything in the cell will take the attributes you specified.

Note that "your class" shouldn't have a space in it.

If you're only using CSS in this one spot, you may wan to do it Inline
(within the HTML). If so, it would look like this:
<td style="font-weight: bold;">stuff in the cell</td>

Otherwise, if you do embedded styles or an external file, your CSS statement
would look like:
#yourclass {
font-weight: bold;
}

or

..yourclass {
font-weight: bold;
}

And the HTML would _almost_ look like Chris suggested:
<td id="yourclass">stuff in the cell</td>

or

<td class="yourclass">stuff in the cell</td>

You can use whatever name you want instead of "yourclass". The difference
between the #yourclass and .yourclass is that the # one is referred to as an
_id_ and can only be used once within your page whereas the . one is called
a _class_ and can be used multiple times within your document.

Like I said earlier, if it's just one cell, inline would be the easiest.

Good luck!
 
So if all I wanted to do was change the font weight to bold, the code would
be just as short if I used html, correct?
 
CSS IS HTML. And the HTML would actually be smaller than using a font tag,
as you can see from Jack's example. The best thing about it is that since
you apply a class across a number of elements, you can change the look of
the entire web by changing the class definitions in the CSS. If you use an
external CSS file, it is a simple matter of making a change in one file.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

Catherine Jo Morgan said:
So if all I wanted to do was change the font weight to bold, the code would
be just as short if I used html, correct?

Jack Brewster said:
Note that "your class" shouldn't have a space in it.

If you're only using CSS in this one spot, you may wan to do it Inline
(within the HTML). If so, it would look like this:
<td style="font-weight: bold;">stuff in the cell</td>

Otherwise, if you do embedded styles or an external file, your CSS statement
would look like:
#yourclass {
font-weight: bold;
}

or

.yourclass {
font-weight: bold;
}

And the HTML would _almost_ look like Chris suggested:
<td id="yourclass">stuff in the cell</td>

or

<td class="yourclass">stuff in the cell</td>

You can use whatever name you want instead of "yourclass". The difference
between the #yourclass and .yourclass is that the # one is referred to
as
 
Back
Top