CSS

B

Blindsya

Hey everybody, I'm using CSS on my site and was just wondering if it
possible to use two different styles on two different <td> tags on the same
page? If so how?
Any help would be much appriciated.
 
M

Mark Parnell

Blindsya said:
Hey everybody, I'm using CSS on my site and was just wondering if it
possible to use two different styles on two different <td> tags on
the same page? If so how?
Any help would be much appriciated.

..td1 {border: 1px solid black;}
..td2 {border: 5px dotted green;}

<table>
<tr>
<td class="td1">foo</td>
<td class="td2">foo</td>
</tr>
</table>
 
B

Blindsya

Blindsya wrote:
Hey everybody, I'm using CSS on my site and was just wondering if it
possible to use two different styles on two different <td> tags on the same
page? If so how?
Any help would be much appriciated.

..td1 {border: 1px solid black;}
..td2 {border: 5px dotted green;}

<table>
<tr>
<td class="td1">foo</td>
<td class="td2">foo</td>
</tr>
</table>


Hey, thanks. Works perfectly!
 
L

Leif K-Brooks

Mark said:
.td1 {border: 1px solid black;}
.td2 {border: 5px dotted green;}

<table>
<tr>
<td class="td1">foo</td>
<td class="td2">foo</td>
</tr>
</table>
Better to use IDs:

#td1 {border: 1px solid black;}
#td2 {border: 5px dotted green;}

<table>
<tr>
<td id="td1">foo</td>
<td id="td2">foo</td>
</tr>
</table>
 
M

Mark Parnell

Leif said:
Better to use IDs:

#td1 {border: 1px solid black;}
#td2 {border: 5px dotted green;}

<table>
<tr>
<td id="td1">foo</td>
<td id="td2">foo</td>
</tr>
</table>

Depending on whether they want to be able to do it more than once in the
same page. If they only want to do it once, yes IDs would be better.
 
B

Brian

Mark said:
Depending on whether they want to be able to do it more than once in the
same page. If they only want to do it once, yes IDs would be better.

If you don't need to use an id as a fragment url, what is the
advantage of id over class?
 
L

Lauri Raittila

you mean to bookmark a part of a document?

No, to post it to usenet ;-). When I quote, I always include first id
upwards to the point I quote - way too often there is none in long time.
If you use id instead if class when id is suitable, you make the id
whitout thinking hard.

Personally I believe that even every paragraph would benefit of id.
Someday I'll write parser that do that automatically.

There might be other reasons, but I don't think I have ever heard any
better.
 
T

Toby A Inkster

Personally I believe that even every paragraph would benefit of id.
Someday I'll write parser that do that automatically.

Disadvantage of that would be that when the document is edited (new
paragraph is inserted, for example) then all the IDs would be renumbered,
breaking any links to them.

(Note to self: use more IDs)
 
L

Lauri Raittila

Toby A Inkster said:
Disadvantage of that would be that when the document is edited (new
paragraph is inserted, for example) then all the IDs would be renumbered,
breaking any links to them.

So, it would be stupid to number those paragraphs, much better use few
first words of paragraph to make ID. And, that would be possible using
RegExp (in fact, I have one that makes it to headings somewhere), so it
would even be easier. Only problem is possibility of identical id's when
paragraphs start exactly same way. OTOH, then I would notice redundantly
starting paragraphs using validator ;-)
 

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,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top