10

The following three pieces of code behave exactly the same:

<p {padding: 0 15 0 15}>  A paragraph of text here...  </p>

<p> A paragraph of text here... </p>

<p style="padding: 0 15 0 15">  A paragraph of text here...  </p>

How do I get the paragraph indented on both sides? (I tried 15px instead of 15 (EDIT - but only on the first two), I also tried separating the numbers with commas, like an example I found on Google.)

The above code is in a div which is in the body, no other divs or tables, etc. are involved.

The div is defined:

<div style="background-color: white; color: black; overflow:auto">

Thanks for any help.

Rilien
  • 242
  • 2
  • 5
  • 11
  • 1
    15px instead of 15 is recommended to make the solution (using "style") work with all browsers. I've seen certain IE-versions ignore values without a unit. http://www.w3.org/TR/REC-CSS1/#units - you're only save to omit the unit when the value is "0". – Select0r Mar 11 '10 at 15:58
  • 2
    In addition to the good answers below, may i suggest firefox and the firebug plugin as being very useful when figuring out your html styling issues. – Paddy Mar 11 '10 at 15:58

3 Answers3

19

15? 15 what? Have you considered using units?

<p style="padding: 0 15px">foo</p>
nickf
  • 537,072
  • 198
  • 649
  • 721
  • 1
    Thanks. I needed both the "style=" and the "px" – Rilien Mar 11 '10 at 16:05
  • 1
    I'd recommend using em instead of px because it's more cross-browser compliant. ie.

    bar

    – jwhat Mar 11 '10 at 17:20
  • 4
    @jwhat Using em instead of px isn't precisely a cross-browser compliance issue. It's more about prioritizing precise design (px) vs text-resizing (em). All browsers these days interpret the units correctly. – Larsenal Mar 11 '10 at 23:47
4

Change:

<p {padding: 0 15 0 15}>  A paragraph of text here...  </p> 

to:

<p style="padding: 0px 15px 0px 15px">  A paragraph of text here...  </p> 
Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222
3

Maybe you have a previous line like this:

p { display: inline }

This CSS disable the use of padding.

Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58