tags:

views:

20

answers:

2

I have been making a wordpress template. i got stuck at some place...

the problem is,

how to maintain the size of a div >= the size of p tags and img tags...

i have seen that the div only able to contain the p tag but the img tag over flows...

i have my code in this following order:

<div>
<p> some contents <img src="an_image"/> some morecontent</p>
<div>

what i basically want is:

div height = <p> height U(union) <img> height

but, what actually i am getting is:

div height = <p> height; while <img> over flows

i have already checked for similar questions on Stack Overflow but was not able to find one which solves a similar problem.. please give me some idea..

an update:

this is my code:

<div id="the_content">
    <p><img class="alignright" src="http://i35.tinypic.com/990wtx.png" alt="WordPress Logo" align="right" />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur quam augue, vehicula quis, tincidunt vel, varius vitae, nulla. Sed convallis orci. Duis libero orci, pretium a, <a href="#">convallis quis</a>, pellentesque a, dolor. Curabitur vitae nisi non dolor vestibulum consequat.  <a href="http://localhost/wordpress/?p=55#more-55" class="more-link">(more&#8230;)</a></p>
</div>
A: 

If you do not specify the height it would wrap around all the elements inside it , why do you want to specify the height?

Ravi Vyas
yeah! that is true when all elements inside it are directly child to that particular div.. here in this case it the img element is inside p and p is inside the div,, its like div(p(img))... the same concept is not working here..even have no control over the inner elements as it is rendering its content from CMS (wordpress)
Idlecool
A: 

You don't show your CSS, but it sounds like you have a floated image inside the div. You may want to try a clearing div after the <p>. Or there are other, newer solutions detailed on Quirksmode.

Robusto
ok! i will check this out! but floats are only possible with div! ryt! there is no other div inside that div,.. all elements are p and img.. and here in my case.. the img is overflowing from the div,. any solution for this?? where can i be possibly getting wrong..
Idlecool
@idlecool: Float is possible inside any block element, also img. But it *is* the div that is collapsing on you.
Robusto
@robusto: yeah! that was a overflow issue, i got the fix for it.. :)i used div#the_content{overflow:hidden;}and it worked :)
Idlecool