div, align and css

Discussion in 'HTML' started by skibud2, Aug 9, 2007.

  1. skibud2

    skibud2 Guest

    Hi All,

    How can I do the equivalent to the following in CSS.

    This aligns the table to the right of the div
    <div align = "right">
    <table> ..</table>
    </div>


    The CSS style:
    ..right {text-align: right;}
    does not work for non text. Am I stuck with putting the align
    attribute directly in? I don't want to use float because this div is
    within a table.

    Thanks in advance,

    Mike
    skibud2, Aug 9, 2007
    #1
    1. Advertising

  2. skibud2

    Ben C Guest

    On 2007-08-09, skibud2 <> wrote:
    > Hi All,
    >
    > How can I do the equivalent to the following in CSS.
    >
    > This aligns the table to the right of the div
    ><div align = "right">
    > <table> ..</table>
    ></div>
    >
    >
    > The CSS style:
    > .right {text-align: right;}
    > does not work for non text.


    No, and there is no standard CSS property that does. Well actually,
    that's not quite true, you _could_ use "direction: rtl" on the div,
    which will cause the table to go to the right. But I wouldn't advise
    using that unless the text is actually in Arabic or another rtl
    language. It could well have undesired side-effects.

    > Am I stuck with putting the align attribute directly in? I don't want
    > to use float because this div is within a table.


    So what? You can float things inside table cells, that's no problem.
    Best to float: right the table, that's the CSS way to do this.
    Ben C, Aug 9, 2007
    #2
    1. Advertising

  3. On Aug 9, 5:23 pm, skibud2 <> wrote:
    > Hi All,
    >
    > How can I do the equivalent to the following in CSS.
    >
    > This aligns the table to the right of the div
    > <div align = "right">
    > <table> ..</table>
    > </div>


    table {
    margin-left: auto;
    margin-right: 0;
    }

    Make sure you use a Doctype that triggers standards mode in IE.

    --
    David Dorward
    http://dorward.me.uk/
    http://blog.dorward.me.uk/
    David Dorward, Aug 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kay
    Replies:
    2
    Views:
    7,146
  2. Andrew
    Replies:
    1
    Views:
    3,585
    Travis Newbury
    Jan 12, 2005
  3. Rafael Cotta
    Replies:
    1
    Views:
    15,569
    Lawrence
    Apr 29, 2005
  4. =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=

    [CSS] Div-Tag and Vertical Align

    =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=, Aug 19, 2006, in forum: HTML
    Replies:
    6
    Views:
    22,510
    dorayme
    Aug 22, 2006
  5. Steve Richter
    Replies:
    1
    Views:
    895
    Mark Rae
    Jun 24, 2007
Loading...

Share This Page