Valid HTML?

Discussion in 'HTML & Website Design' started by NaSh123, Feb 17, 2009.

  1. #1
    With the current setup of my site I have the following
    <div><table><tr><td><a href></td><a href><a href></td></tr></table></div>

    Would it be ok to do
    <div><a href><table></table></a></div>

    I basically want to elimination repeating my <a href=""></a> 3 times because everything inside the DIV links to the same place, except each piece of content is different, so i link an image, text, and a buy now button

    I want to avoid the onClick on the div because of the possibility of javascript being disabled.
     
    NaSh123, Feb 17, 2009 IP
  2. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #2
    No you cannot. <a> is an inline element. Tables are not.
     
    drhowarddrfine, Feb 17, 2009 IP
  3. truivia

    truivia Active Member

    Messages:
    467
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Nash go to w3.org and use their free html verifier
     
    truivia, Feb 17, 2009 IP
  4. NaSh123

    NaSh123 Peon

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What other method would you recommend to get what I want done? I have no choice but to put an onClick on the div?
     
    NaSh123, Feb 17, 2009 IP
  5. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #5
    As suggested above a table is a block element, so you have to ask yourself is the table nessecary.

    For example could you put the information inside a SPAN element, which is an inline element and you could then wrap your anchors (a) around the SPAN.

    <div><a><span></span></a></div>

    It depends on what goes inside the anchor as you could possibly even get away without using a SPAN at all. So if you need help further post up some example code.
     
    wd_2k6, Feb 18, 2009 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    What is your data? The obvious answer is probably don't use a table...

    Without seeing what you are plugging in for data, it's hard to say your best approach, though I suggest you learn what elements are 'inline-level' and 'block-level' (which is NOT the same thing as the css display properties)
     
    deathshadow, Feb 19, 2009 IP
  7. SiteTalkZone

    SiteTalkZone Peon

    Messages:
    243
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If there is only one line in your table it is probably best you don't use one at all. Try an unordered list <ul>.

    <div><table><tr><td><a href></td><a href><a href></td></tr></table></div> - This is defiantly invalid.
     
    SiteTalkZone, Feb 19, 2009 IP
  8. NaSh123

    NaSh123 Peon

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I basically have.
    DIV
    Table
    then 2 TDs (left one an image: right side text)
    close table
    close div

    I'm currently just using the onClick event on the DIV
     
    NaSh123, Feb 19, 2009 IP
  9. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #9
    So what exactly is the use of the table, doesn't seem like it has one.

    What is wrong with:
    
    <div class="myDiv">
        <a href="mylink/htm">
           <img src="myimg.jpg" />
           <span>My Text</span>
        </a>
    </div>
    
    Code (markup):
    You can style the P and IMG to look and appear wherever you want, and they will both be a linked to the same page.

    It's best to only use tables for tabular data.
     
    wd_2k6, Feb 19, 2009 IP
  10. NaSh123

    NaSh123 Peon

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ah so you mean put the image and the text and maybe put a float left on the image?
     
    NaSh123, Feb 19, 2009 IP
  11. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Yeah you can organise it however you want really.
     
    wd_2k6, Feb 20, 2009 IP
  12. mrpaisa

    mrpaisa Guest

    Messages:
    741
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    <html>
    <title>as</html>
    <head>as</head>
    <body>
    <p>
    valid HTML code
    </p>
    </body>
    </html>
     
    mrpaisa, Jan 13, 2010 IP
  13. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #13
    Huh, thread necro of a year old post, NEITHER post of which seems to have ANYTHING to do with what was being discussed... (the first of which is completely invalid order)

    Just trying to get your post counts up so you can start spamming the services section or something, or is this just a total /FAIL/ rooted in engrish moist goodry?
     
    deathshadow, Jan 14, 2010 IP