When to use the p tag in html

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

Can somebody give a good example when to use the p tag.
I know it's a paragraph

//Tony
 
Can somebody give a good example when to use the p tag.
I know it's a paragraph

If you are sufficient XML oriented then you should have <p></p> around
all your text blocks.

Arne
 
Arne Vajhøj said:
If you are sufficient XML oriented then you should have <p></p> around
all your text blocks.

Arne

I mean if it's only static text I don't need any p tag

//Tony
 
I mean if it's only static text I don't need any p tag

You really should use it all the time.

Not the 1995 style:

This is paragraph 1.
<p>
This is paragraph 2.

but XML style:

<p>This is paragraph 1.</p>
<p>This is paragraph 2.</p>

Arne
 
Tony Johansson said:
I mean if it's only static text I don't need any p tag

Then your page will not validate - http://validator.w3.org/
If your page does not validate then it might cause problems or not render as
you'd expect in some browsers, and bots might have problems. So, like Arne
has already posted, you should use them (correctly) all the time.
 
I mean if it's only static text I don't need any p tag

//Tony
use <p> when you want to create a block level element. There are an awful lot of
"Programmers" who use this pattern instead:

<table><tr>
<td> .... content ... </td>
</tr></table>
(*)

A perfect candidate to replace with <p>

<p> .... content ... </p>

Alternatively, you can use <div>...</div> if you are intending to have some nested
elements in there (and not just flowing text). <P> just means its more or less plain
text contained.

(*) And yes, I am serious, I have seen this pattern time and time again. Countless
tables that contained just one cell, all because people didn't know how to create or
style block level elements.

Ax
 
Back
Top