开发者

specified body CSS width is safe?

开发者 https://www.devze.com 2023-02-10 11:38 出处:网络
Now very often content with a certain size centered. <html> <head> <style type=\"text/css\">

Now very often content with a certain size centered.

<html>
<head>
  <style type="text/css">
    #content { margin: auto; width: 960px;}
  </style>
</head>
<body>
   <div id="content">Blah!</div>
</body>
<开发者_如何学JAVA;/html>

Is it safe to not use a wrapper for alignment and size, and apply it directly to a body tag? Like this:

<html>
<head>
   <style type="text/css">
      body { margin: auto; width: 960px;}
   </style>
</head>
<body>
   Blah
</body>
</html>


The size is safe, however the margin: auto-centering isn’t completely.

You have to add text-align: center to the body style to center it in IE6, too. (Yeah, I know, it totally makes no sense, but that’s hoe IE6 works)

0

精彩评论

暂无评论...
验证码 换一张
取 消