You can use calc, modern browsers support it and IE9+ as well.
div {
margin: 10px;
width: calc(100% - 20px);
height: 10px;
background: teal;
}
<div></div>
More Related Contents:
- div 100% width with other div fixed
- How to design an HTML/CSS signature that will work in Outlook 2016? [duplicate]
- How to align 3 divs (left/center/right) inside another div?
- CSS: Width in percentage and Borders
- Can ordered list produce result that looks like 1.1, 1.2, 1.3 (instead of just 1, 2, 3, …) with css?
- Does opacity:0 have exactly the same effect as visibility:hidden
- :after and :before CSS pseudo elements hack for Internet Explorer 7
- CSS image resize issue
- Is it possible to style a mouseover on an image map using CSS?
- Floating an image to the bottom right with text wrapping around
- HTML: Changing colors of specific words in a string of text
- HTML + CSS: Ordered List without the Period?
- How to change content on hover
- How can I style a file input field in Firefox?
- How can I center a div within another div? [duplicate]
- Flexbox resize and scrollable overflow [duplicate]
- How do I make Firefox auto-refresh on file change?
- Second line in li starts under the bullet after CSS-reset
- Can I override inline !important?
- How position absolute and fixed block elements get their dimension?
- Ring-shaped process spinner with fading gradient effect around the ring
- Why is there a default margin on the element? [closed]
- set css border to end in a 90 instead of a 45 degree angle
- text-decoration not working for visited state link
- Setting max-height for table cell contents
- click link below a higher z-index div [duplicate]
- Pseudo element not full container width when border used
- Setting the image `width: 0` hides it, while `width: 0%` makes it occupy the space, too
- How to play CSS3 transitions in a loop?
- HTML canvas with scrollbar