The width spreads across the whole page, i only want it to be as long as the content in the div. How can i solve this?

<style type="text/css">
.three {
display:block;
width:auto;
height:100px;
position:relative;
border:1px solid black;
}

.three a {
width:100%;
height:100%;
position:absolute;

}

</style>
echo "<div class='three'><a href='two'></a>test</div>";

Remove position:absolute

tried that and it doesn't work.

.three a {
width:100%;
height:100%;
position:absolute;
 
}

The question to ask here is: 100% of what? The answer: The browser window. Give .three a set width.

Regards
Arkinder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.