Skip to content

Instantly share code, notes, and snippets.

@Gekkio
Created March 25, 2011 13:46
Show Gist options
  • Save Gekkio/886846 to your computer and use it in GitHub Desktop.
Save Gekkio/886846 to your computer and use it in GitHub Desktop.
Don't use width: 100% on block-level elements unless you know exactly what you're doing!
<html>
<body>
<div style="background-color: red; margin: 20px; width: 100%">
Fail (margin: 20px; width: 100%)
</div>
<div style="background-color: red; margin: 20px">
Success (margin: 20px)
</div>
<div style="background-color: red; padding: 20px; width: 100%">
<div style="background-color: green">
Fail (padding: 20px; width: 100%)
</div>
</div>
<div style="background-color: red; padding: 20px">
<div style="background-color: green">
Success (padding: 20px)
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment