link a background-image / div

Discussion in 'HTML' started by Marco Lehmann, Nov 4, 2003.

  1. hi guys,

    i have a div, in which a table and a text is located.
    with css i defined a background-image laying under the div.
    now i want to link the whole div with an a-tag.
    w3c's validator says, that a construct like:

    <a href="...">
    <div id="...">
    <table ...>
    ...
    </table>
    </div>
    </a>

    isn't valid because the div-tag seams to be misplaced
    inside the a-tag.
    i got this validation message:

    document type does not allow element "DIV" here; missing one of
    "APPLET", "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag

    what's the solution?
    thanks in advance.

    marco
     
    Marco Lehmann, Nov 4, 2003
    #1
    1. Advertising

  2. Marco Lehmann

    Steve Pugh Guest

    Marco Lehmann <> wrote:

    >i have a div, in which a table and a text is located.
    >with css i defined a background-image laying under the div.


    Okay, might be a bit over-complex but okay.

    >now i want to link the whole div with an a-tag.


    You can't do that.

    >w3c's validator says, that a construct like:
    >
    ><a href="...">
    > <div id="...">
    > <table ...>
    > ...
    > </table>
    > </div>
    ></a>
    >
    >isn't valid because the div-tag seams to be misplaced
    >inside the a-tag.


    Yup.

    Don't nest the <div> inside the <a>. Without knowing more about your
    page (such as what data goes into the table and why you want an entire
    table full of data to be a single link) it's hard to suggest an
    alternative.

    Steve



    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Nov 4, 2003
    #2
    1. Advertising

  3. Hi Steve,

    the only reason for linking a whole layer is,
    that I probably have to change the text nested in the
    table several times and I don't want to create a
    graphic over and over again.

    Here is the complete listing of the relevant part:

    <a href="specials.html" class="tabLink">
    <div id="specialTab">
    <table width="100" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td width="100" height="40">
    &nbsp;<br>
    </td>
    </tr>
    <tr>
    <td width="100" height="20">
    Specials<br>
    November 2003<br>
    </td>
    </tr>
    </table>
    </div>
    </a>

    Hopefully this will help a little bit.
    Thanks in advance.

    Marco
     
    Marco Lehmann, Nov 4, 2003
    #3
  4. Marco Lehmann wrote:

    > Here is the complete listing of the relevant part:


    <snip>

    Why is there a table there at all? I can't believe you possibly want to
    describe a relationship between a non-breaking space with a line break and
    what looks like a heading.


    --
    David Dorward http://dorward.me.uk/
     
    David Dorward, Nov 4, 2003
    #4
  5. David Dorward wrote:

    > Marco Lehmann wrote:
    >
    >
    >>Here is the complete listing of the relevant part:

    >
    >
    > <snip>
    >
    > Why is there a table there at all? I can't believe you possibly want to
    > describe a relationship between a non-breaking space with a line break and
    > what looks like a heading.
    >
    >


    The div will be moved while the mouse cursor is over the
    table. Therefore the div consists of a table, which
    arranges the text and the space in the right way. The
    distance between the top of the div and the text must be
    exact.

    Marco
     
    Marco Lehmann, Nov 4, 2003
    #5
  6. Marco Lehmann wrote:

    > <a href="...">
    > <div id="...">
    > <table ...>
    > ...
    > </table>
    > </div>
    > </a>


    Not allowed. You might technically be able to do this:

    <a href="...">
    <object>
    <div id="...">
    <table ...>
    ...
    </table>
    </div>
    </object>
    </a>

    but this is likely to perform strangley in some browsers. Better to just
    link the content of each table cell.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
     
    Toby A Inkster, Nov 4, 2003
    #6
    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. Jean-Louis Crouzet

    Table td with background image & link & image

    Jean-Louis Crouzet, Jul 21, 2005, in forum: HTML
    Replies:
    4
    Views:
    1,668
    Jean-Louis Crouzet
    Jul 23, 2005
  2. jc
    Replies:
    3
    Views:
    1,783
  3. jc
    Replies:
    1
    Views:
    1,407
    Neredbojias
    Mar 19, 2008
  4. K Viltersten

    <div ... /> and <div ...></div>

    K Viltersten, Mar 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    807
  5. Dwayne Madsen

    Q: Div A inside Div B is larger than Div B

    Dwayne Madsen, Jun 1, 2005, in forum: Javascript
    Replies:
    1
    Views:
    235
    David Dorward
    Jun 1, 2005
Loading...

Share This Page