Web Analytics Made Easy -
StatCounter xHTML... is this a solid definition? - CodingForum

Announcement

Collapse
No announcement yet.

xHTML... is this a solid definition?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • xHTML... is this a solid definition?

    I just went through the tutorial at w3schools.com about xHTML, and I want to make sure this is right. xHTML is just another version of HTML, with some differences:

    1. The opening and closing tabs must be lowercase, and properly nested/terminated.
    2. All single line tags like <br> and <hr> etc are to be closed with <br /> and so on.
    3. It's basically a "neater" form of HTML.

    I know there are others, but is xHTML just a clean-freak version of HTML? If so, fantastic!

  • #2
    In essence, yes. It is actually the same language but written in XML instead, except for some obscure differences because of XML limitations that doesn't exist in SGML.

    Don't forget that attribute names are also lowercase, including event handlers. Many posters here forget that.
    liorean <[[email protected]]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

    Comment


    • #3
      Originally posted by liorean
      Don't forget that attribute names are also lowercase, including event handlers. Many posters here forget that.
      Yep. Got it.

      I'm a bit confused though... where does the XML part of xHTML come in? XML is a way of storing info for processing, and from what I see, xHTML is just a stricter HTML. Some similar attributes I see are stuff like "id" instead of "name", etc.

      Comment


      • #4
        And all attributes need to be quoted, and all shortened attributes (eg noshade) now become noshade="noshade".
        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!

        Comment


        • #5
          Oh, XML is not that much different from SGML. XML does not provide much more to the language than SGML does, and just some more than tagsoup. It does put some limitations, though:

          - All elements in XML needs to be terminated. Since XHTML is HTML4.01 in XML form, this rule affects XHTML.
          - All elements in XML needs to be correctly nested. In SGML they also needed that, but browsers were in general a bit looser in their error handling and allowed it.
          - XML does not allow attribute minimisation.
          - XML is case sensitive, and all XML attributes and elements are lowercase.
          - Content in comments should not be parsed in XML, which means you may not put scripts or stylesheets in comments.
          - &, <, > and " should ALWAYS be replaced by the corresponding entity if they are not inside a CDATA block. This includes scripts, stylesheets, urls in attributes etc.
          - Documents SHOULD be sent as 'application/xhtml+xml', MAY be sent as 'text/xml' or 'application/xml', and MAY be sent as 'text/html' under the condition that they conform to the compatibility guidelines as specified by the XHTML1.0 spec. XHTML1.1 and later MUST NOT be sent as 'text/html'.

          I'm sure I forgot something, but that's what I could think of right now...
          liorean <[[email protected]]>
          Articles: RegEx evolt wsabstract , Named Arguments
          Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
          Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

          Comment


          • #6
            Re: xHTML... is this a solid definition?

            Originally posted by Steveo31
            2. All single line tags like <br> and <hr> etc are to be closed with <br /> and so on.
            Just to clarify, it's really that elements have no "value" or "text", and therefore the opening and closing elements are condensed into a single self-contained element. The <img /> element would be another example.
            Marcus Tucker / www / blog
            Web Analyst Programmer / Voted SPF "ASP Guru"

            Comment


            • #7
              On top of the neater stuff, certain tags require certain attributes. Forms require the action attribute even if empty, and all images require the alt attribute. Some tags have also been dropped and marked as depricated.

              There is much more to it than this. Images are displayed differently. For example, in XHTML, if you have img tags on separate lines in your source, the images will not be side by side. I'm uncertain of other changes, but these are critical for layouts.

              I'm trying to redo my sliding puzzle (http://xfox.digibase.ca/web/games/slide/miles) into a compliant and Mozilla friendly version. I'm dropping the idea of splitting each image into their own cell. I'm using nested padded div tags instead of table alignment. It's 4x4, so 4 imags per row, 4 rows. But there's some spacing between lines with images in XHTML. I tried specifying 0 for padding and margins and it doesn't fix it. If each image were still in their own td cell, display:block would fix this. But since they're in a div and adopting a CSS layout, display:block stacks the images. How do I fix this? http://xfox.digibase.ca/web/games/sl...les/slide2.htm has the example problem.
              Go to:
              http://www.TailsArchive.net/
              http://xfox.proboards21.com/

              Comment


              • #8
                Thanks for the addition of the required attributes.

                Why don't you copy+paste the rest of that into a new thread so people will help you.

                Comment


                • #9
                  Originally posted by Steveo31
                  Yep. Got it.

                  I'm a bit confused though... where does the XML part of xHTML come in? XML is a way of storing info for processing, and from what I see, xHTML is just a stricter HTML. Some similar attributes I see are stuff like "id" instead of "name", etc.
                  XML is a way of marking up information. Any information you like. XHTML is an application of XML that is used to mark up Hypertext Information, in otherwords, the contents of a webpage. As such, all presentational elements are being phased out as XHTML is for marking up information and just that, not formatting it. That is entirely down to CSS.
                  Luke Redpath

                  Comment


                  • #10
                    Originally posted by Tails
                    Images are displayed differently. For example, in XHTML, if you have img tags on separate lines in your source, the images will not be side by side. I'm uncertain of other changes, but these are critical for layouts.
                    That is incorrect. Images are by default inline elements, and as such MUST be contained within a block element (such as div or a p element) and as such will display horizontally...inline. Which line the elements are on in the source *should* make no difference whatsoever.
                    Luke Redpath

                    Comment


                    • #11
                      Here's a strange thing I noticed. I was trying to teach a friend how to clean up his page and teach him the good habits of using the XHTML DTD. I gave him what he needed to copy and paste. He pasted it and made a sample page containing all the required elements. But his document wouldn't validate. It must have been discouraging enough for him for me to say "some's not working." If I'm the one teaching him and I don't know what's wrong, he's definately lost.

                      Anyway, the validator couldn't detect the character encoding because he had the XML declaration on the second line instead of the first. (all he did was press 'enter'). I don't know how you can make a DTD become as strict as that. It defies the freedom of whitespace in markup doesn't it?
                      Go to:
                      http://www.TailsArchive.net/
                      http://xfox.proboards21.com/

                      Comment


                      • #12
                        Actually, Tails, it's a requirement of XML 1.0 (not the DTD) that the XML declaration, if included, have nothing before it. No comments, no whitespace, nothing. It must be the first characters in the document.

                        So it's not the DTD's fault
                        "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
                        June 30, 2001
                        author, ES-Membrane project (Github Pages site)
                        author, Verbosio prototype XML Editor
                        author, JavaScript Developer's Dictionary
                        https://alexvincent.us/blog

                        Comment


                        • #13
                          Originally posted by Alex Vincent
                          Actually, Tails, it's a requirement of XML 1.0 (not the DTD) that the XML declaration, if included, have nothing before it. No comments, no whitespace, nothing. It must be the first characters in the document.

                          So it's not the DTD's fault
                          I also hear that in order for Microsoft to work outside of Quirks Mode (like that would ever happen...Microsoft doesn't even have a doctype), the DTD must be on the first line. They accept one standard by violating the next.
                          Go to:
                          http://www.TailsArchive.net/
                          http://xfox.proboards21.com/

                          Comment

                          Working...
                          X