When to use the p tag in html


T

Tony Johansson

Hello!

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

//Tony
 
Ad

Advertisements

A

Arne Vajhøj

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
 
T

Tony Johansson

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
 
A

Arne Vajhøj

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
 
B

Brian Cryer

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.
 
Ad

Advertisements

A

Axel Grude

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
 
Ad

Advertisements


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

Top