2 replies [Last post]
putts
putts's picture
Offline
Regular
Michigan
Last seen: 13 years 23 weeks ago
Michigan
Joined: 2007-04-30
Posts: 32
Points: 0

Playing with the TryIt feature at w3schools, I'm able to get the following code working perfectly...

This tablecell has a top and bottom padding of 0.5cm and a left and right padding of 2.5cm.

However, for whatever reason, w3schools doesn't apply any DOCTYPE to their HTML Previewer and as soon as I try either of the following, it mucks up

The Box with the Red border (the inner div) will expand beyond the constraints of the containing box (the div with the black border).

What is the proper way to do this so that I can pad a div within another div and yet not extend beyonde the constraints of that first div?

TIA

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 5 years 46 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Dont apply a width to the

Dont apply a width to the inner element let it just naturally take the width of it's parent.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

putts
putts's picture
Offline
Regular
Michigan
Last seen: 13 years 23 weeks ago
Michigan
Joined: 2007-04-30
Posts: 32
Points: 0

That worked. Thanks

That worked.

Thanks