G
G
Georgy Grigoriev2013-09-16 16:05:37
Google Chrome
Georgy Grigoriev, 2013-09-16 16:05:37

One div falls into another

In the case of two empty closed divs, after rendering, one gets into the other:
Source:

<html>
<head></head>
<body>
  <div id="up"/> 
  <div id="prop"/> 
</body>
</html>


Result:
<html>
<head></head>
<body>
  <div id="up">
    <div id="prop"></div>
  </div>
</body>
</html>

Why is this happening? Moreover, if you specify blocks as an open and closed tag, this does not happen.
Source:
<html>
<head></head>
<body>
  <div id="up"> </div>
  <div id="prop"/> 
</body>
</html>


Result:

<html>
<head></head>
<body>
  <div id="up"></div>
  <div id="prop"></div>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
AxisPod, 2013-09-16
@IamKarlson

Because in HTML it is not a single tag and cannot be. Similar behavior for other block tags.

M
Maxim Timokhin, 2013-09-16
@timokhin

Supply doctype XHTML and content-type text/xml

A
Andrey Burov, 2013-09-16
@BuriK666

What doctype?

@
@xave, 2013-09-16
_

Set the correct xhtml docktype, preferably strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question