WordPress.org

Ready to get started?Download WordPress

Ideas

Use HTML doctype NOT XHTML

  1. Rocknation
    Member

    I've managed to put together a XHTML strict WP theme. The widgets work except the search form and the Recent Comments.

    Here is strict-compliant search form code:

    <form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p>
    <input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" size="12" />
    <input type="submit" id="ssubmit" value="SEARCH" />
    </p>
    </form>

    Here is strict-compliant flash/YouTube embed code:

    <object width="425" height="344">
      <param name="movie"
             value="http://www.youtube.com/v/dMH0bHeiRNg&hl=en&fs=1">
      </param>
      <param name="allowFullScreen" value="true"></param>
      <embed src="http://www.youtube.com/v/dMH0bHeiRNg&hl=en&fs=1"
             type="application/x-shockwave-flash" allowfullscreen="true"
             width="425" height="344">
      </embed>
    </object>

    And use this javascript (target_blank.js) if you want to target="_blank" (write rel="target_blank" instead)"

    function externalLinks() {
      if (!document.getElementsByTagName && document.getElementById) return;
    
      var anchors = document.getElementsByTagName("a");
    
      for (var i=0; i<anchors.length; i++) {
       var anchor = anchors[i];
       if (anchor.getAttribute("href") &&
           anchor.getAttribute("rel") == "target_blank")
           anchor.target = "_blank";
     }
    }
    window.onload = externalLinks;

    ProfitOnlineForBeginners.com is still in the planning stages. But now that I've solved the problems I've had with XHTML Strict, I can live with it!

    Posted: 4 years ago #
  2. gormer
    Member

    Couldn't agree more. Serving XHTML as HTML, like WordPress does, makes little sense.

    Posted: 4 years ago #
  3. Covi
    Member

    12345

    @Briansage: Without the application mime type, XHTML practically is HTML strict -- it's simply a different set of strict syntax.

    XHTML is HTML Strict?? You can merge doctypes?; you can embed, natively, SVG,
    Math..?; xml:attrs..., portability?
    Your XHTML can be SVG, RSS, Atom... with a simple XSLT.

    HTML is HTML, and nothing else;
    XHTML is XML, ...so: SVG, Math, GML, RSS, PDF... and your data remain intact, pure and simple, without modifications.
    DATA; STRUCTURE; PRESENTATION.

    Html is not, by far, nothing close to XHTML 1.1/2.0 (real xml). I not talking about Transitional.

    Posted: 4 years ago #
  4. doug
    Member

    John Kilroy is correct in all his comments about XHTML. You may think your website is XHTML, but unless the MIME type is set correctly, it is not. It is interpreted by every browser as invalid HTML.

    And if your MIME type is set correctly, then any parsing errors will result in a Yellow Screen of Death and IE won't display it at all.

    XML is great for data storage and transfer, but is not great for serving webpages. Are you really using XSLT to transform webpages into RSS? WordPress already outputs valid RSS.

    And yes, SVG and MathML can both be embedded in HTML5 natively.

    John's request is unnecessary, though, for the simple reason that HTML5 doesn't care about trailing slashes. Just change the DOCTYPE of your theme to HTML5 and it will be valid whether your generator outputs HTML or XHTML!

    Posted: 4 years ago #
  5. doug
    Member

    Just want to clarify one point I made yesterday: Data in WordPress is not stored as XML.

    When the data is published (usually as a webpage or RSS feed), the XML/SGML structure is created on the fly (using unreliable string manipulation). Publishing as XHTML so that you can then transform it to RSS or some other XML language makes no sense since you can just publish directly to RSS if you need it (which WP does).

    Insisting that the content always be published as (fake) "XHTML" is pointless unless it is actually used as XML (which it isn't).

    Posted: 4 years ago #
  6. lupinek
    Member

    12345

    I prefer using XHTML in my themes. Awaiting for the HTML 5 release we should encourage Microsoft to add XHTML support to their newest browser (finally!).
    And I am pretty sure that there are not 65% of visitors of my websites who use MSIE – according to Google's statistics.

    Posted: 4 years ago #
  7. demetris
    Member

    The new default theme that’s coming with WordPress 3.0 uses the HTML5 doctype:

    <!DOCTYPE html>

    I think this will solve the issue to most people’s satisfaction. :-)

    Posted: 4 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    25 Votes
  • Status

    This is theme territory