Chappers Posted November 23, 2008 Share Posted November 23, 2008 Hi everyone, After years of using tables, I'm having a mid-table crisis. It was after coming across this problem again: <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td colspan="2"> <p class="text">Hello world.</p> <p class="text">And hello again in a new paragraph block.</p> </td> </tr> <tr> <td><p class="text">I want to show you a picture.</p></td> <td width="110" align="center"><img src=gimp.jpg"></td> </tr> <tr> <td colspan="2"> <p class="text">More text.</p> </td> </tr> </table> Now the trouble with the above: With just one <td> and all the text contained within different paragraphs <p></p> there is an empty line between each paragraph, separating them neatly. Since I want images at the side of some paragraphs, it means I have to do what the code above shows - end the initial <td> and create others so the image can go in its own. Trouble with that is that the neat gaps between paragraphs is lost and the text just displays in one large block. To add a space between paragraphs, I have to add <br> at the end of a paragraph before closing the <td> and beginning the next. That leaves a much bigger gap than the <p> normally gives and so looks bad. I can't see a way around it, so I got looking into divs again, even though I'd been warned before not to use them. I can't yet remember how to use them to display the code above as I'd want it, but regardless, is it the best way to go? Or is there an alternative to tables and divs? What's best? Someone please help! Thank ye, James Quote Link to comment Share on other sites More sharing options...
dropfaith Posted November 23, 2008 Share Posted November 23, 2008 what someone said dont use divs? ive never heard that and wnet to divs as soon as it seemed possible to run on only divs and never even thought about looking back divs are way better then tables imo but you could just add this to your p class in stylesheet p.text {margin-bottom:5px;} and adjust the height to your needs and then no need for the br tag as you get a controlable gap at the bottom of your p Quote Link to comment Share on other sites More sharing options...
Chappers Posted November 23, 2008 Author Share Posted November 23, 2008 But within <td>s where I am using multiple <p>s one after another, wouldn't I then have a gap made up of standard <p> gap and the extra 5px set to bottom margin? Quote Link to comment Share on other sites More sharing options...
dropfaith Posted November 23, 2008 Share Posted November 23, 2008 yes maybe i misunderstood here im playing with a simpple div of what your doing il brb Quote Link to comment Share on other sites More sharing options...
dropfaith Posted November 23, 2008 Share Posted November 23, 2008 okay in the end this will give you a hell of a lot more control using css and divs instead of tables.. i just did a quick mock up of what you had for code <style> div.wrapper {width:100%;} div.full {width:100%;} div.text {width:75%;float:left;text-align:left;} div.image {width:24%;float:right;} p.text {padding:0;margin:0;} </style> <div class="wrapper"> <div class="full"> <p class="text">Hello world.</p> <p class="text">And hello again in a new paragraph block.</p> </div> <div class="text"> <p class="text">I want to show you a picture.</p> </div> <div class="image"> <img src="4.png" /> </div> <div style="clear:both;"> </div> <div class="full"> <p class="text">More text.</p> </div> </div> Quote Link to comment Share on other sites More sharing options...
otuatail Posted November 25, 2008 Share Posted November 25, 2008 Could be wrong, but I belive serch engines detest tables. If you want them to improve your rankings keep away from them. Desmond. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 25, 2008 Share Posted November 25, 2008 Tables should never be used for formatting, only for displaying Tabular Data. That is my opinion at least. Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 25, 2008 Share Posted November 25, 2008 Tables should never be used for formatting, only for displaying Tabular Data. That is my opinion at least. I think that's general consensus by now. Quote Link to comment Share on other sites More sharing options...
plasmagames Posted December 1, 2008 Share Posted December 1, 2008 Divs all the way. the code is easier to read and edit, the code looks a hell of a lot cleaner. Tables are only for new coders, if you have been using them for a while switch now. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 1, 2008 Share Posted December 1, 2008 newer coders shouldn't use tables if you were new why would you learn the old style of doing things its pointless if your learning css html or anything at least put the effort to learn the newest of the codes Quote Link to comment Share on other sites More sharing options...
CroNiX Posted December 2, 2008 Share Posted December 2, 2008 Tables should never be used for formatting, only for displaying Tabular Data. That is my opinion at least. I think that's general consensus by now. Its also been the w3c standard for at least 6 years, so it should be everyone's consensus. Quote Link to comment Share on other sites More sharing options...
plasmagames Posted December 3, 2008 Share Posted December 3, 2008 good point so ya get rid of tables use divs only Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.