Hello. I have a loop of code that displays the name and description of an element. Everything works fine unless one of the text fields is longer than the specified css width. The text will wrap, which is great, however, when it loops around to display the next element it writes the text on the same line. Shouldn't a text wrap automatically place a <br> tag in the html?
below is the code written in PHP.
foreach ($viewSeries as $key) {
?>
<div id="tblLeft">Name:</div>
<div id="tblRight"><? echo htmlspecialchars($key['Name']); ?></div>
<br />
<div id="tblLeft">Description:</div>
<div id="tblRight"><? echo $key['Description']; ?></div>
<br />
<?
}
below is the css file for tblLeft and tblRight.
#tblLeft {
position: absolute;
margin: 0px 0px 0px 3px;
width: 150;
text-align: right;
font-weight: bold;
padding-right: 5;
background-color : #DDD;
border-bottom: 1px solid #222;
border-top: 1px solid #BBB;
}
#tblRight {
position: absolute;
margin: 0px 0px 0px 162px;
width: 500;
text-align: left;
font-weight: normal;
color: #222;
white-space: -moz-pre-wrap;
}
CSS DIV tags not going to next line
Hi Warped,
Try changing the position values to relative.
Could you link to an example if you are still having problems.
Re: CSS DIV tags not going to next line
Shouldn't a text wrap automatically place a <br> tag in the html?
No, unfortunately htmlspecialchars isn't that clever... since the width is in a CSS file, and the PHP code doesn't have anything to do with it. However the rendering of the page should do what you want if you follow Tony's advice.
THAT WORKED!!!!
tony thank you so much. that worked perfectly.