Results 1 to 7 of 7

Thread: Invalid tag attributes required; is that a problem?

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default Invalid tag attributes required; is that a problem?

    I'm working on a project involving one of the scripts here on DD (the anylink menu) and it requires the rel attribute.
    The doctype for the site is XHTML strict, and this can't be avoided because I'm integrating it with a forum that uses this. The script works fine.

    There are other similar cases where attributes aren't valid but they work. One that comes to mind is target.

    For these extra features on a page (opening a link in a new window, applying a Javascript action to a tag, etc.) there is no harm if it doesn't work, since these don't even necessarily need a fallback. They're extra fancy things anyway.

    So my question is what to do about the fact that the page won't validate due to "unknown" attributes. Of course the browsers appear entirely happy about it.

    Another way to ask the question is this: is it safe to just ignore the validator as long as I understand that nonstandard attributes may not always work, since they're for extra features anyway?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Is the page being served with a mime type of "application/xhtml+xml" (e.g., via server configuration or php header() call; the <meta> tag doesn't cut it )?

    If not, then xhtml validation is largely unrelated to how the page will function. The browser is treating it as error-corrected html anyway.

    Of course, if it is being served correctly, then IE <9 won't show it at all, but offer a file download dialog.

    ...

    I wouldn't worry about it. It should work fine.

  3. The Following User Says Thank You to traq For This Useful Post:

    djr33 (02-13-2011)

  4. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm not doing anything special with it, so I suppose it isn't being served with that mime type.
    Here's the shared top throughout the site:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    PHP is not setting a header, but this also matches what the forum does.

    As long as it works, that's fine with me.

    This is also a theoretical question, though:
    What is the best way to deal with the fact that, for example, many of the scripts on Dynamic Drive are invalid, at least for XHTML strict? I know that I will continue to use them, and that they work. So we should just ignore the validator?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #4
    Join Date
    Sep 2010
    Location
    Hi Stalker.
    Posts
    148
    Thanks
    16
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by djr33 View Post
    So we should just ignore the validator?
    I ignore it all the time I struggled and struggled trying to get my code right and it never worked. I ignore it, do I believe you could and/or should too

  6. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I think xhtml should be actively discouraged, for the simple reason that most (meaning almost all) " xhtml " pages are actually being served with the html mime-type, and therefore, not being rendered as xhtml anyway. HTML is better at being HTML than xml is. Additionally, HTML5 has the generic data-{whatever} attribute for the express purpose of passing data to scripts - ideal!

    Realistically, though, I don't see any easy way around your theoretical problem. All of the scripts would need to be rewritten to make use of valid attributes (e.g., using a class name instead of the rel).

  7. The Following User Says Thank You to traq For This Useful Post:

    djr33 (02-13-2011)

  8. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That makes sense. At the moment I'm just working with what I have, so there's no easy to way to make everything work well as HTML5 and class attributes, for example. But perhaps in 5 years most code will have adjusted itself to be standardized.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    lol, you know how many sites I run across that still use HTML3? well, at least I haven't seen a HTML2 site lately.

    as far as "working with what you have" goes, completely understandable. It's how the world works
    Last edited by traq; 02-13-2011 at 06:45 PM.

Bookmarks

Posting Permissions

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