Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is <html> visually?

Tags:

html

Does the scroll bar belong to <html> or <body>?

I've been writing for every html file,but don't know exactly what it is.

like image 890
omg Avatar asked Nov 28 '22 08:11

omg


2 Answers

Given the following markup and styling:

<!DOCTYPE html>

<html>
<head>
<title></title>
<style type="text/css">
html {
 background: green;
 overflow:scroll;
}
body {
 background: red;
 overflow:scroll;
}
</style>
</head>
<body>

</body>
</html>

We get the following visual results:

Firefox 3.5

Firefox 3.5 http://img98.imageshack.us/img98/3448/ff35.png

Internet Explorer 6

Internet Explorer 6 http://img98.imageshack.us/img98/870/ie6.png

Opera 10

Opera 10 http://img22.imageshack.us/img22/1395/o10.png

Google Chrome 3

Google Chrome 3 http://img193.imageshack.us/img193/4300/82451373.png

So, we can style the HTML element. In fact some people use this in combination with the BODY tag to get complicated backgrounds.

like image 63
Ionuț G. Stan Avatar answered Dec 26 '22 14:12

Ionuț G. Stan


<html> has no visual. It just defines that the document is a html document and it contains the head and the body.

It's the body that has the view.

The scroll bar belongs to the window if you talk about DOM.
But in CSS, you set scrollbar styles through <body>

If you use Firebug on Firefox and use the element inspector (the one where you can move your mouse and point around elements of the HTML document, and you point it at blank space where there's no elements there, it points to the <body>.

like image 22
mauris Avatar answered Dec 26 '22 14:12

mauris