DIV <inline> not displayed

V

Vik

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>Untitled Page</title></head>
<body>
<div style="DISPLAY: inline; WIDTH: 100px; HEIGHT: 100px"></div>
</body>
</html>


A DIV element with <DISPLAY: inline> setting is not displayed at all.
If I remove or make incorrect a <!DOCTYPE... > line (that is created
automatically) then DIV is displayed.
What is wrong here?

Thanks.
 
Joined
May 16, 2006
Messages
27
Reaction score
0
<Display: inline> works on my side,

try using HTML 4.0 instead of XHTML 1.0 in the following statement,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
S

Scott M.

Your div's style does not have any visible characterstics to see and no
content. If you added a style setting for something that you can see, like
a background color, you'll see the div.

-Scott
 
B

bruce barker

you have incompatible styles. if an element is inline, then there are no
height, or width properties. removing the doctype removes the
requirement to be standards based, so height and width may work with
some browsers.

-- bruce (sqlwork.com)
 
V

Vik

In VS2003 the inline div with or without content is always visible in the
designer (the div's border is displayed). If a control is placed in this
div, then the control can be posioned in the center of the div.

In VS2005 the inline the div without content disappears from the designer
and a browser even with the background color. If a control is placed into
this div then the div's size reduces to the size of the control and control
can not be posioned in the center of the div (this is what I need).

Thanks.
 
V

Vik

Thanks.
Please see my reply above.

Vik

bruce barker said:
you have incompatible styles. if an element is inline, then there are no
height, or width properties. removing the doctype removes the requirement
to be standards based, so height and width may work with some browsers.

-- bruce (sqlwork.com)
 
S

Scott M.

I don't believe the behavior has changed in either version of VS, but either
way, Bruce has answered your question. With an inline div (essentially a
span), you don't specify height and width as the element is "in line" with
its parent container. A div, in ths case, will always be as wide as its
content is - - if there is no content, there is no space allocated to the
div. If you put a control in the div, then the div will be as big as the
div.

Again, I don't believe this behavior has changed in any version of VS.

For what you are doing, you really should use a <span> element, as that is
contextually more appropriate.

-Scott
 
V

Vik

My test shows that the behavior depends on the DOCTYPE specs. With the
following DOCTYPE (created by the VS2003) the inline div keeps its
dimensions even without content:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Vik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top