/    Sign up×
Community /Pin to ProfileBookmark

Quick and Simple Nesting Divs for Layout Question

Hello. Im getting good at usiing divs for layouts, I just have a quick question:

When nesting a div within a div, should i alot for a pixel in my widths? say for instance i have a div that is 200px wide, then i want to nest a div inside that, should i make that width 198px?

I assume that other things like setting margin and borders apply, im just wondering about general rules to follow, thanks

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelApr 13.2006 — Great question, though!

I would say that if the nested DIV had a border of say, 1px and margin:0;, then yes, it should be two pixels less-wide than the containing DIV (to allot for the left and the right and we assume here that the height is much less than the height of the container DIV).

I have never encountered this occurance...it will be interesting to see what others have to add. ? I wonder though, -what if the nested div were wider than the container div BUT it was z-index:2 (one higher than container)? Then, would that not matter, or would it compromise the container div anyway?
Copy linkTweet thisAlerts:
@ray326Apr 14.2006 — As long as the inner div is unadorned it should fit with the same dimensions. We are talking about web browsers here and not IE, right?
×

Success!

Help @decibel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...