views:

59

answers:

2

How to give border to any element using css without adding border-width to the whole width of element?

Like in Photoshop we can give stroke- Inside , center and outside

alt text

I think default css border properties is center like center in photoshop, am i right?

I want to give border inside the box not outside. and don't want to include border width in box width.

A: 

Thus, you're trying to achieve the same as the well known IE box model bug? That's not possible. Or you want to support clients with IE on Windows only and choose a doctype which forces IE into quirksmode.

BalusC
+1  A: 

In your case can you fudge it by subtracting half the border from the padding? (-2.5 from the padding if your border is 5px wide, you can't have negative padding so to go smaller reduce the overall width of the box). You can add an extra 2.5px to the margin to keep the overall box the same size.

I really don't like this suggestion, but I don't think there is a way do handle this cleanly.

vfilby