Click to See Complete Forum and Search --> : replace 'P' tag with a class?


solly
07-07-2008, 05:31 AM
Hi everyone,

I'm bug fixing on a site that has div's nested within paragraph tags which don't comply to xhtml validation. I want to create new classes that match what a P tag does. Does anyone know what properties the 'P' tag has? i.e. padding:5px?

Thanks in advance.

:)

Fang
07-07-2008, 05:37 AM
Padding varies between browsers. Set it to your own requirements.

Centauri
07-07-2008, 06:17 AM
What a <p> tag "does" is denotes a paragraph of text. How it is normally rendered is up to the browser, but typically it is rendered as a block element with top and bottom margins, which as Fang has suggested, varies between browsers.

Declan1991
07-07-2008, 07:20 AM
Why would you want to have a div inside a paragraph element?

jgs240
07-07-2008, 09:59 PM
Why would you want to have a div inside a paragraph element?

If i read it correctly, i think he is trying to fix that problem. :)

felgall
07-07-2008, 10:20 PM
The needed fix is to get rid of the div tag (unless the "paragraphs" are not really paragraphs and that tag has been misused). Anything inside a paragraph needs to be inline within the paragraph and a div tag can't be inline (unless you are overriding it in the stylesheet to make it identical to a span tag).

Declan1991
07-08-2008, 07:59 AM
If i read it correctly, i think he is trying to fix that problem. :)
I was trying to find out which was incorrect, the p or the div. Depending on that, the solution is totally different.

Centauri
07-08-2008, 09:23 AM
I was trying to find out which was incorrect, the p or the div.

That depends totally on the content contained within.

solly
07-08-2008, 10:14 AM
Hi guys, thanks for the replies, it's much appreciated.

I'm bug fixing for British Airways and some of the development is slightly unorthodox hence the div inside the p tag. I've managed to sort it out anyway, I just added padding at 10px 10px 0px and it looks exactly the same in IE and FF.

Much appreciated. :)

felgall
07-08-2008, 05:20 PM
Adding padding doesn't sound like a valid fix for having a div inside a p where it isn't allowed. You either have to change the div to a span or change the p to a div.

solly
07-10-2008, 06:30 AM
I've changed the P to a class in my .css and the <p> to <div class="paraFix"> and it's working fine now, thanks for the brainstorm fellas.

felgall
07-10-2008, 03:56 PM
A more meaningful name for the class would make it easier to maintain in the future. The <p> should never have been there in the first place since it isn't a paragraph and so the class name paraFix is somewhat misleading.