Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use <body> in place of #container div?

Tags:

css

xhtml

Can we give width and border to <body> and use in place of Container div? see this example

see source code of this file and code of file is also perfectly W3C valid. and looking same in IE 7 and firefox 3.5.

<!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" lang="en" xml:lang="en" dir="ltr">
  <head>
    <title> Width in body</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <style type="text/css">
      html { background-color: #00f; }
     body{background: #cd5c5c;width:800px;height:400px;border:1px solid;color: #fff;margin:0 auto;}
     </style>
  </head>
   <body>
     <p>Hello world!</p>

   </body>
</html>
like image 600
Jitendra Vyas Avatar asked Nov 10 '09 17:11

Jitendra Vyas


People also ask

Can I use body wash instead of shampoo?

While you can use body wash as shampoo once (or vice versa) in a while, it is not advised to do so regularly. Using a body wash on your hair could affect the pH level of your scalp, while a shampoo could change the pH level of the skin. This leaves your scalp or skin prone to damage, dryness, and other issues.

Can I use body wash for face?

The skin on your face is far more delicate than the skin on your body. Facial cleansers have specific formulas to remove makeup and unclog pores. Facial skin is more sensitive than the skin on the rest of your body, so it's best to avoid using body wash on your face.

Can you use body wash as moisturizer?

It's great for moisturizing: Bar soap is infamous for drying out skin, whereas body wash is better at moisturizing because many contain lotions or oils.

Can body moisturizer be used on face?

The bottom line. Putting body lotion on your face once or twice probably won't cause any lasting harm. All the same, body lotion isn't meant for facial skin, so it could make some skin concerns worse. Sticking to products specifically formulated for your face will generally do more to benefit your skin in the long run.


1 Answers

Your example answers your question! Body is a block element like any other. It has width, height, padding, margin and border properties.

  • Note that it is essential that the page is rendered in strict, rather than quirks, mode to be able to treat the body element as a block-level element; otherwise it is treated as the documentElement and all bets are off. – NickFitz

Then can we use body in place of #container div? – Jitendra

  • Nice theory. Shame about Microsoft. – David Dorward
  • @Jitendra: you can, but be thorough with your cross-browser testing, particularly when it comes to scrolling :-) – NickFitz

What is the difference between viewport and body? – Jitendra

  • the viewport is the visible area of the browser window which displays the document. The body is an element in the document. In quirks mode, the body will also be treated as the documentElement: that is, the root node of the document, which will fill the window, and if necessary will be able to be scrolled. In strict mode, the html element will be treated as the documentElement, and the body will be a child of that. As an experiment, change your test page by adding the style rule html { background-color: #00f; } - you will see that the html element contains the `body' – NickFitz
like image 50
2 revs Avatar answered Oct 27 '22 01:10

2 revs