Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts

    xhtml capitalization

    Do attributes like these: onClick, onSubmit have to be capitalized like so? In my html validator, it says: "All open tags, end tags, and tag attributes must be in lowercase because this is an XHTML document." If not, why are they written like that (with a capital letter)?

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    They shouldn't.
    I also used onClick (with capital) but then my page wouldn't validate. I was wondering why and someone pointed out my attributes should all be lowercase.

    onclick is the right way to do it
    Shawn

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Really? Because in regular HTML, case of tags makes no difference... I haven't used XHTML yet though.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    For regular HTML, your right, but for XHTML, all tags and attributes must be lowercase.
    Shawn

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts
    thanks for the info. Some time ago, i heard that it must be capitalized. I think it was: onMousever or something like that. But maybe that's a different case... But for now, I'll stick with lowercase.

  • #6
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I don't think onMouseover needs to be capitalized, HTML (and XHTML) is not case-sensitive.
    Shawn

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Event handlers never did need to be capitalized - in HTML you can still go "onclick" or "Onclick" or "ONCLICK". It was only camel cased out of convention really - no actual need.

    But XHTML *is* case sensitive - it must be all lower case.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #8
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    DOH, I was writting a little too fast there
    Shawn

  • #9
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts
    What about something like this:
    <td bgcolor="#000000" onmouseout="bgColor='#000000'" onmouseover="bgColor='#FFFFFF">hello</td>

    I'm not sure if that's valid, but I noticed when you change the C in Color to a lowercase c, the effect doesn't work.

    THanks for the help.

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's not the same though - that's a property name, which must have the right camel casing, because javascript is also case sensitive.

    btw - should be "this.bgColor"
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #11
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    yeah, bgColor ain't HTML, it's javascript.
    Shawn

  • #12
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts
    ok

  • #13
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    Originally posted by qwertyuiop
    What about something like this:
    <td bgcolor="#000000" onmouseout="bgColor='#000000'" onmouseover="bgColor='#FFFFFF">hello</td>

    I'm not sure if that's valid, but I noticed when you change the C in Color to a lowercase c, the effect doesn't work.

    THanks for the help.
    In any case, XHTML doesn't allow the bgcolor attribute anymore. It's been marked as depricated. XHTML relies on CSS whenever possible and doesn't allow certain tags and attributes, such as <center>, align="", etc. It was quite a pain for me to break the habit of typing HTML in capitals, but I'm used to it now. Although I occasionally slip up with the shift when typing in lowercase and then using shift for angle brackets <>.

    Oh, and beware of any auto-correcting editors. If they have some option to convert all tags to lowercase, be sure the DOCTYPE is still in caps or you'll get strange validation errors.

  • #14
    Banned
    Join Date
    Jan 2004
    Location
    Minneapolis, MN
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "camelcase"

    that's such a great term. one i've never heard in the past several years i've been doing this web/scripting hullaballoo..

  • #15
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is sort of on topic:

    Just so you don't get confused: XML does allow uppercase letters. The only reason that you can never use uppercase in XHTML attribute/element names is that XML is case sensitive and no element with uppercase letters exists in XHTML. ie: there is no such tag as <IMG/>. You probably want the tag <img/>.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!


  •  

    Posting Permissions

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