3 replies [Last post]
Man26
Offline
newbie
Last seen: 18 years 30 weeks ago
Joined: 2004-05-06
Posts: 3
Points: 0

I have a text, to which I want attaching a class.
¿What is the better method?

this?
<td><span class="prices"><p>Price One</p></span></td>
or:
<td><p class="price">Precio One</p></td>

co2
co2's picture
Offline
Leader
UK
Last seen: 14 years 33 weeks ago
UK
Joined: 2003-09-17
Posts: 721
Points: 0

Better method to ataching class

The first example is wrong, you can't have an inline element (the span) wrap round a block element (the paragraph). By stating this is wrong, I mean by W3C standards guidelines (the HTML validator will also throw it up as an error).

The second example is more like it. YOu could even add a class to the td, and not use the paragraph at all. IF the text is for tabulated data, then I would say remove the paragraph tag and add the class to the td.

Smile

The next sentence is true. The previous sentence is false. Discuss...

Man26
Offline
newbie
Last seen: 18 years 30 weeks ago
Joined: 2004-05-06
Posts: 3
Points: 0

Better method to ataching class

Thanks co2
but within the tag TD I am going to have other texts (or <p>?) with other classes each one.
In this case is rigth use it:
<td><p class="one">one</p><p class="two">Two</p></td>?
And what is the use of tag <span>?

co2
co2's picture
Offline
Leader
UK
Last seen: 14 years 33 weeks ago
UK
Joined: 2003-09-17
Posts: 721
Points: 0

Better method to ataching class

The span tag is to amend inline elements such as:

<p>This is a <span class="test">good use of a span tag</span></p>

The next sentence is true. The previous sentence is false. Discuss...