Smart Archives Reloaded
[resolved] HTML error "document type does not allow element " (5 posts)

  1. swissspaceboy
    Posted 1 year ago #


    Just installed this plugin and my html validator gives now an error for all pages where SAR is loaded.
    Error message is

    line 940 column 214 - Error: document type does not allow element "link" here

    due to this code that is found at the end of the <body>.

    Any one has a fix for this ?

    <script type='text/javascript' src='http://.../plugins/smart-archives-reloaded/inc/tools.tabs.min.js?ver=1.1.2'></script>
    <script type='text/javascript'>
    jQuery(function ($) { $('head').prepend('<link rel="stylesheet" id="smart-archives-css"  href=".../plugins/smart-archives-reloaded/inc/styles.css?ver=2.0" type="text/css" media="all" />'); });
    </script><script type="text/javascript">
    jQuery( document ).ready( function( $ ) {
    	$( '.tabs' ).tabs( '> .pane' );
    	$( '#smart-archives-fancy .year-list' )
    		.find( 'a' ).click( function( ev ) {
    			$( '.pane .tabs:visible a:last' ).click();
    		} ).end()
    		.find( 'a:last' ).click();
    } );


  2. scribu
    Plugin Author

    Posted 1 year ago #

    Your HTML validator is naive; it shouldn't check HTML inside <script> tags.

    You should try the official validator from W3C: http://validator.w3.org/

  3. swissspaceboy
    Posted 1 year ago #

    Hi Scribu,

    Thanks for answering. I'm using the official W3C validator of course.

    Here is the full output of the page check:

    Error Line 1313, Column 215: document type does not allow element "link" here
    …archives-reloaded/inc/styles.css?ver=2.0" type="text/css" media="all" />'); });
    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
    One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

    They propose to escape the html code with //<![CDATA[ //]]>

    like in this example :

    <script type="text/javascript">
    var output = "<html><body><p>Hi!<\/p><\/body><\/html>";

    Do you have some ideas how to change this in files util.php or core.php ?



  4. swissspaceboy
    Posted 1 year ago #

    @all : this is my fix. As I have moved the css of this plugin to my theme stylesheet, there is no need to register the stylesheet.
    So in file core.php, function add_scripts(), comment out this piece of code :

    if ( $add_css ) {
    			$css_dev = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
    				$plugin_url . "styles$css_dev.css",
    			scbUtil::do_styles( 'smart-archives' );

    This will avoid having a W3C validator error. Not great as fix but it works.

  5. scribu
    Plugin Author

    Posted 1 year ago #

    I guess I'll have to eat my words.

    The //<![CDATA[ makse sense, since it's an inline script.

    Here's the change I made: https://github.com/scribu/wp-scb-framework/commit/e1e7cf6d6d6a578c3507bb9f52eb4b70b8fc3f90

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Smart Archives Reloaded
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.