www.webdeveloper.com
Results 1 to 9 of 9

Thread: align table inside a table

  1. #1
    Join Date
    Apr 2003
    Posts
    137

    align table inside a table

    Hi Y'all, sorry I haven't been here in a while.

    I've recently started studying CSS and I'm trying to get the hang of it.
    I'm so used to the old html method it's hard to break.

    I have a table inside a table, and I can align right using the old method,
    but I cannot seem to align right using CSS.

    old method, (and still works)
    Code:
    <table><tr><td align="right">
    <table><tr><td> text </td></tr></table>
    </td></tr></table>
    new method
    Code:
    <table><tr><td style="text-align:right">
    <table><tr><td> text </td></tr></table>
    </td></tr></table>
    I have tried as many ways as I could to get it to work,
    just short of banging on the monitor.

  2. #2
    Join Date
    Apr 2003
    Posts
    137
    sorry, I think I found it

    styles="float:right"

    it's not working as I wanted, but I think I can make due.

  3. #3
    Join Date
    May 2014
    Posts
    681
    My question would be why do you have a table inside a table? Are you using tables for layout like it's still 1997 or something?

    Really that's something you shouldn't even have in your markup in the first place if you are using tables for tabular data... It's almost as silly as making tables where there are only one TD per TR. (or one TR for the whole table for that matter).

    Though if it IS tabular data, without seeing a sample OF that data it's hard to say what the proper markup OR proper CSS would be.
    Java is to JavaScript as Ham is to Hamburger.

  4. #4
    Join Date
    Apr 2003
    Posts
    137
    nope, it's not working right.

  5. #5
    Join Date
    Apr 2003
    Posts
    137
    Quote Originally Posted by deathshadow View Post
    My question would be why do you have a table inside a table? Are you using tables for layout like it's still 1997 or something?

    Really that's something you shouldn't even have in your markup in the first place if you are using tables for tabular data... It's almost as silly as making tables where there are only one TD per TR. (or one TR for the whole table for that matter).

    Though if it IS tabular data, without seeing a sample OF that data it's hard to say what the proper markup OR proper CSS would be.
    I have code from years ago and all of it was assembled using tables.
    I wanted to convert all of it to CSS so I could learn CSS.
    Most all of it is calculating numbers so alignment is critical.
    If you think I should move away from tables, I probably could.
    Just about the time I learned html 4.01, several generations have
    passed me by.
    http://www.anothenservices.com/calculator/wallcalc.html

  6. #6
    Join Date
    May 2014
    Posts
    681
    Ok, looking at what you have, the INNER tables are sufficiently 'tabular' I'd say sure, use a table on that... but your OUTER tables, and in fact most of the tables on your page serve NO legitimate purpose. The table around the H1? Pointless. The table around the other tables? Pointless.

    Of course, your original has two doctypes, so that's kinda funny.

    Sadly, when most people "learned" HTML 4.01 they never actually learned HTML... there were so many bad practices and pointless coding methods still in circulation, nobody back then was able to even learn what HTML is or how to use it right; a trend that sadly continues to this day.

    One of the keys to learning to use CSS is rethinking how your HTML is built... particularly if you learned the -- what we now call sloppy and bad -- method of building sites with endless "table for nothing".

    ... even using tables -- you seem to have multiple tables doing the job of one table -- you have no relationship between the rows, they're multiple tables side-by-side for... well, I don't know what for. If everything is on a row, put them in a TR, if that means empty TD, so be it. Empty TD is certainly better than trying to make multiple side-by-side-by-side tables line up with each-other.

    Even back then, you've got a whole slew of markup for nothing, and most of it is tables for nothing; that page should have -- by my reckoning -- six tables for the actual tabular data; there should be no tables inside tables, H1 inside tables -- hell if you're going to use tables the heading text for each table you have inside <br> should be a CAPTION.
    Java is to JavaScript as Ham is to Hamburger.

  7. #7
    Join Date
    Apr 2003
    Posts
    137
    Thanks Shadow,
    Yeah, the newer version I'm using html 5, your seeing my original.
    All of the javascript code works just fine as long as I maintain
    all of it within the form. What I'll do is start experimenting using
    a minimum of tables. I'm still stumbling through CSS, but I see it
    as a great benefit from having to endlessly repeat the same styling code.

  8. #8
    Join Date
    Apr 2003
    Posts
    137

  9. #9
    Join Date
    May 2014
    Posts
    30
    Use this code for displaying nested table and also inner table contain align to right.


    <table>
    <tr>
    <td>
    <table style="float:right:">
    <tr>
    <td></td>
    <td></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles