Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

css

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

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.

like image 494
Jitendra Vyas Avatar asked May 01 '10 02:05

Jitendra Vyas


People also ask

Does border Add to width CSS?

By default in the CSS box model, the width and height you assign to an element is applied only to the element's content box. If the element has any border or padding, this is then added to the width and height to arrive at the size of the box that's rendered on the screen.

How do I keep the border from changing size in CSS?

To avoid the width or height getting increased or decreased when using CSS properties like margin , padding , etc, we can use the CSS property called box-sizing and set its value to border-box on the element in CSS.

How do I add a border to an entire page in HTML without CSS?

Using Inline Style attribute Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the inline property for adding the border. Step 2: Now, place the cursor inside the opening tag of that text around which we want to add the border.

How do you put a border around a border in CSS?

Answer: Use the CSS box-shadow property If you want to place or draw the borders inside of a rectangular box there is a very simple solution — just use the CSS outline property instead of border and move it inside of the element's box using the CSS3 outline-offset property with a negative value.


1 Answers

outline:1px solid white; 

This won't add the extra width and height.

like image 178
abenson Avatar answered Sep 20 '22 13:09

abenson