Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Centering tables on page

Options
  • 21-09-2013 1:22pm
    #1
    Closed Accounts Posts: 4,339 ✭✭✭


    I'm making a basic webpage and I want it all to be centered on the page but I'm having a bit of trouble with the tables.

    I can center the images with <div align=center> etc. But to get the tables to sit side by side I had to align them to the left using <table style="float: left" width="300" border="1">. So adding "align=center" to the Div tag has no affect.

    I know I shouldnt be using tables to begin with but this is basic html and CSS isnt an option. Just really need to know if its possible to center align these blocks of tables simply.

    This is the code for the tables:
    <!DOCTYPE html>
    <HTML>
    <HEAD>
    <TITLE>Home</TITLE>
    </HEAD>
    
    <BODY bgcolor="">
    
    
    <div>
    <table style="float: left" width="300" border="1">
    <tr>
    <td colspan="2" style="background-color:#;">
    <h1>Topic</h1>
    </tr></td></table>
    <table style="float: left" width="300" border="1">
    <tr>
    <td colspan="2" style="background-color:#;">
    <h1>Topico</h1>
    </tr></td></table>
    <table style="float: left" width="600" border="1">
    <tr>
    <td colspan="2" style="background-color:#;">
    <h1>Topic</h1>
    </tr></td></table>
    </div>
    
    
    <div>
    <table style="float: left" width="300" border="1">
    <tr>
    <td colspan="2" style="background-color:#;">
    <h2>Subtopic</h2>
    info
    </tr></td></table>
    <table style="float: left" width="300" border="1">
    <tr>
    <td colspan="2" style="background-color:#;">
    <h2>Subtopic</h2>
    info</tr></td></table>
    <table style="float: left" width="300" border="1">
    <tr>
    <td colspan="2" style="background-color:;">
    <h2>Subtopic</h2>
    info
    </tr></td></table>
    <table style="float: left" width="300" border="1">
    <tr>
    <td colspan="2" style="background-color:;">
    <h2>Subtopic</h2>
    info
    </tr></td></table></div>
    <br>
    
    
    <BODY></HTML>
    


Comments

  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    Your tags are overlapping for a start

    [HTML]<tr>
    <td colspan="2" style="background-color:#;">
    <h2>Subtopic</h2>
    info
    </tr></td>[/HTML]

    should be

    [HTML]<tr>
    <td colspan="2" style="background-color:#;">
    <h2>Subtopic</h2>
    info
    </td>
    </tr>[/HTML]

    If you're presenting tabular data, there's nothing wrong with using tables.

    If you're using tables for layout/positioning, 1 kitten dies for each table cell you use. :mad:


  • Closed Accounts Posts: 4,339 ✭✭✭Artful_Badger


    Graham wrote: »
    If you're presenting tabular data, there's nothing wrong with using tables.

    If you're using tables for layout/positioning, 1 kitten dies for each table cell you use. :mad:

    For what I'm doing and what I know about getting it done tables are my best bet for this regardless of how wrong it is to use them for positioning. There's too many kittens poking about these days anyway. :D

    I fixed the overlapping tags. As far as positioning goes though is it possible to get those groups of tables center aligned ?


  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    You could nest your existing tables into the cells of a larger table.

    That should work but then Panda bears start to die.

    Seriously, look at css. You're already using some css in what you have already, it really wouldn't take you much (minutes not hours) .


  • Closed Accounts Posts: 4,339 ✭✭✭Artful_Badger


    Graham wrote: »
    You could nest your existing tables into the cells of a larger table.

    That should work but then Panda bears start to die.

    Seriously, look at css. You're already using some css in what you have already, it really wouldn't take you much (minutes not hours) .

    What css am I using already ? Its not that I'm lazy and not bothered looking into it I'm just trying to work with what I know to get this one particular thing done as as far as I'm aware thats whats expected of me.

    Its not that big of a deal if I get it aligned or not. But I'm gonna give that nested table a crack and see how many Pandas die.


  • Closed Accounts Posts: 4,339 ✭✭✭Artful_Badger


    The nested table business worked, thanks very much. Sorry about the Kittens and Pandas....


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    Each of those style= tags that you have peppered across your restaurant proportion quantity of tables is inline css. :pac:

    Glad it worked out though.


Advertisement