简体   繁体   中英

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?

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.

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.

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