W3C validator does not pass <nobr> tag

1k views Asked by At

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?

2

There are 2 answers

0
toesslab On BEST ANSWER

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.

2
Dave Burton On

It's a bug -- but in the HTML 5 spec, more than in the validator. W3C needs to fix the spec. <nobr> should properly be in the spec, because it is needed to convey important semantic information: namely that the enclosed content is semantically a single unit, which should not be split by line breaks.