HTML/CSS: Creating a centered div with a min-width
- by Alessandro Vernet
I'd like to have on my page a div which is centered and has a certain width, but which extends beyond that width if required by the content. I am doing this with the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
.container-center {
text-align: center;
}
.container-minwidth {
min-width: 5em;
display: inline-block;
border: 1px solid blue;
}
</style>
</head>
<body>
<div class="container-center">
<div class="container-minwidth">
a
</div>
</div>
</body>
</html>
This works great on Firefox/Safari, but not on IE6, which doesn't understand the display: inline-block. Any advice on how to make this work on IE6 as well?