Search code examples
htmlw3c-validation

W3C validator does not pass <nobr> tag


I'm using this piece of code:

<div class="home_notizia_page_riassunto">
   <?php echo get_the_excerpt();?>
   <a href="<?php echo get_permalink();?>">  <nobr>- <span style="color:red;"> Leggi tutto </span></nobr></a>
</div>

But I get this errore in W3C validator:

Element nobr not allowed as child of element a in this context.

I tried to put nobr in many place but the problem still remains the same. Any suggestion?


Solution

  • The <nobr> tag is deprecated in HTML 5. Use CSS white-space instead:

     <a href="<?php echo get_permalink();?>">
         <span style="white-space: nowrap">- <span style="color:red;"> Leggi tutto </span>
         </span>
     </a>
    

    From the W3 wiki:

    The white-space property specifies how white-space inside an element is handled.