Place the element in the top right corner of the <span> in IE

I am having trouble positioning an element (div) in the upper right corner of a range. It works in FF3, but not IE7:

<html>
<head>
<style>
body
{
    font-size: 24px;
}

.tag
{
    padding: 3px;
    background-color: lightblue;
    position: relative;
}

.x
{
    position: absolute;
    top: 0px;
    right: 0px;
    width: 10px;
    height: 10px;
    background-color: orange;
}
</style>
</head>
<body>
text <span class="tag">tag<div class="x"></div></span> text 
</body>
</html>

      

In FF3, a 10x10 orange box is displayed in the upper right corner of the blue square. I am having trouble getting this to work in IE7. Thanks!

0


a source to share


2 answers


First, create the correct document type for your page so that it doesn't show up in quirks mode.

W3C: Recommended DTD List



Second, make sure the code is valid. You cannot wrap a block element (div) inside an inline element (span).

W3C markup validation

+3


a source


you can also see this post if you have problems with positioning in IE7 in the future



0


a source