I was recently trying to build a HTML5 webpage (using the<!DOCTYPE html> tag)
and I made a centered page with a border radius, which with the DOC. it was fluid, but without it was fine. I was wondering, what am I doing wrong? How can include the doctype and make it work?
Here’s the code:
<html>
<head>
<style>
body
{
background: #373;
margin:0;
}
#container
{
background:transparent;
padding:24;
}
#page
{
display: block;
background:#eee;
width: 850;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
margin: 0 auto;
padding:5px;
}
</style>
</head>
<body>
<div id="container">
<div id="page">
Testing 1 2 3
</div>
</div>
</body>
</html>
Copy and paste into this.
The problem appears to be the non-zero
widthandpaddingattributes; any non-zero width needs to have a unit specified:The following seems to work, albeit I don’t necessarily know what your desired end-result is:
JS Fiddle demo.
And the ‘before’ version, with your own html/css for comparison.
References: