Question: I have been long away from HTML and CSS, can't find the solution to this simple problem.

I have one div inside the other. Outer Black and inner orange.

[![enter image description here](https://i.stack.imgur.com/hsZkE.gif)](https://i.stack.imgur.com/hsZkE.gif)

My HTML and CSS is :

```css
#outer {
  position: fixed;
  width: 30%;
  height: 30%;
  background-color: black;
}
#inner {
  width: 100%;
  height: 100%;
  margin: 5px;
  background-color: orange;
}
```

```html
<div id="outer">
  <div id="inner">
  </div>
</div>
```

Why is my inner DIV spilling out of the outer ? How do I fix it without giving fixed dimensions?

Answer: 
Because of the margin - the width is 100% PLUS the margin. To avoid that, write `width: calc(100% - 10px);` (= twice the margin.) Same for height.

```css
#outer {
  position: fixed;
  width: 30%;
  height: 30%;
  background-color: black;
}
#inner {

  width: calc(100% - 10px);
  height: calc(100% - 10px);
  margin: 5px;
  background-color: orange;
}
```

```html
<div id="outer">
  <div id="inner">
  </div>
</div>
```
You can convert from `margin` to `padding`, as inner space of element, and assign to **#outer**.

Then, the result will appear as your expect.

```css
#outer {
  position: fixed;
  width: 30%;
  height: 30%;
  background-color: black;
  padding: 5px;
}
#inner {
  width: 100%;
  height: 100%;
  background-color: orange;
}
```

```html
<div id="outer">
  <div id="inner">
  </div>
</div>
```