简体   繁体   中英

Stray start tag a

I am currently using validator.w3 and I got this kind of error:

Line 90, Column 1420: Stray start tag a.
…-home menu-item-18"><a href="http://www.perthtakeaways.info/">Home</a></option>
✉
Error Line 90, Column 1428: Stray end tag a.
…-home menu-item-18"><a href="http://www.perthtakeaways.info/">Home</a></option>
✉
Error Line 91, Column 180: Stray start tag a.
…enu-item-33"><a href="http://www.perthtakeaways.info/about/">About</a></option>
✉
Error Line 91, Column 189: Stray end tag a.
…enu-item-33"><a href="http://www.perthtakeaways.info/about/">About</a></option>
✉
Error Line 92, Column 200: Stray start tag a.
…="http://www.perthtakeaways.info/getting-started/">Getting Started</a></option>
✉
Error Line 92, Column 219: Stray end tag a.
…="http://www.perthtakeaways.info/getting-started/">Getting Started</a></option>
✉
Error Line 93, Column 190: Stray start tag a.

This error is from the navigation menu named nav.php the nav.php is:

<nav id="nav" role="navigation" class="col_4 omega">
    <?php
    $menu = wp_nav_menu(
            array('topmenu' => 'Top Menu', 'fallback_cb' => 'purepress_nav_fallback', 'echo'=>0 )
    );

    $menu = str_replace("\n", "", $menu);
    $menu = str_replace("\r", "", $menu);

    echo $menu;

    ?>
    <?php
    wp_nav_menu(array(
            'mobilemenu' =>'Mobile Menu',
            'walker'         => new Walker_Nav_Menu_Dropdown(),
            'items_wrap'     => '<select id="mobile-nav"><option value="/">Select Page</option>%3$s</select>',
    ));
?>
</nav><!-- #nav -->

since wp-menu is auto generated by wordpress code this is the things shown in validator.w3 came from wp_menu_template.php:

The code for tha stray end tag error is:

<div><ul id="menu-main-menu" class="menu"><li id="menu-item-18" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-18"><a href="http://www.perthtakeaways.info/">Home</a></li><li id="menu-item-33" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-33"><a href="http://www.perthtakeaways.info/about/">About</a></li><li id="menu-item-36" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-36"><a href="http://www.perthtakeaways.info/getting-started/">Getting Started</a></li><li id="menu-item-34" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-34"><a href="http://www.perthtakeaways.info/contact-us/">Contact Us</a></li><li id="menu-item-35" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-35"><a href="http://www.perthtakeaways.info/faqs/">FAQs</a></li><li id="menu-item-102" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-102"><a title="Member&#8217;s Login" href="http://www.perthtakeaways.info/wp-login.php">Login</a></li></ul></div> <select id="mobile-nav"><option value="/">Select Page</option><option value="http://www.perthtakeaways.info/" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-18"><a href="http://www.perthtakeaways.info/">Home</a></option>

This code is from wp_menu_template.php and I'm curious why this error happen?..I think nothing is wrong with the code because is is auto generated by wordpress.

The problem is that you are taking PHP code and putting it into the validator. This is not correct.

The PHP code should be run on a web server to produce HTML. This resulting HTML can be fed to the validator. One way is to input the URL of the PHP web page in the HTML validator, http://validator.w3.org/ or you can save the resulting HTML and use the "Validate by Direct Input" in that validator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM