Hi, i have just replaced a table (which i was using for the layout of my site) with divs. However i'm not sure what the best way is to display my data using divs. I want to be able to place data under neath one another so i used the <br> tag to bring each div down to the next line - however this has left too big of a gap between each line data. Before i was able to adjust the <tr> height to adjust the space between each line. I know i can just take out the <br> and apply a margin to each div but in html how does each div know that it is to be displayed on the next line <div> text here </div> <div> text here </div> <div> text here </div> <div> text here </div> <div> text here </div> <div> text here </div> <br> <div> text here </div> <br> <div> text here </div> <br> <div> text here </div>
Well, divs will come in the next line unless it uses some class to float. As you know, using margin would be the best of option.
first of all define the width of that div id and you can use float:left and setting to display:block, so it automatically comes below other. but although it comes naturally down of above..!! best regards,
What does the width have to do here ? and is float/display: block needed here ? I mean it will come below anyway.
The div element does not by itself change the way the page looks at all. You can write a term paper/report with <p>s and stick <div> all over and save as html page and it will look like you did nothing (the divs don't show up). A div is a box element, so when you are styling with CSS then yes each div box will stack by default (easily changed though). But, if this text really is table info, go ahead and use a table. They're not forbidden, it's just that people use them for whole pages which is not the purpose of tables. If you just want lines of text, you can do <p>Here's some text</p> <p>And more text</p> <p>And some more.</p> or <p>Here's some text<br /> And a bit more<br /> And lastly<br /> This</p> Code (markup): which make new lines inbetween the last end tag and first new tag. If it's a list, use <ul> which also will automatically make a new line. In CSS you can also set the space between the text (you say it's too far apart now), where you set your font-size, you can set line-height. Not sure I understand, div boxes don't know what's in the next div box. If all the div boxes holding your data are the same (same sizes and they all look like clones etc) then assign them all a class, and in CSS under that class set a bottom margin of however much space you want before the next div box comes.
well you can set a width to width:65% or width:230px; anything u like it so that it covers only that portion and will display block and it comes below one by one !! regards,