HTML validation. Website is invalid when using tel inside href

So, I get this error when I try to test it here :

Bad tel cost: 0000 00 00 00 for href attribute on element a: Invalid character in schema data: not url code point

My html looks like this:

<a href="tel:0000 00 00 00">0000 00 00 00</a>

      

Is there a way to fix this?

+3


source to share


3 answers


Take spaces. Literal spaces are not allowed in URLs, and they are not part of the phone number data, but are simply formatted for human consumption.



+3


source


Assuming the validator validates the URL against the grammar given in RFC 3966 , it does not work on whitespace characters. Remove them or replace them with a character visual-separator

(like -

) and you should be fine.

Example:

<a href="tel:0000-00-00-00">0000 00 00 00</a>

      

Section 3 of the specification has a grammar. In particular:



phonedigit           = DIGIT / [ visual-separator ]
visual-separator     = "-" / "." / "(" / ")"

      

See also Section 5.1.1 which says

although ITU-T E.123 recommends using spaces as visual separators in printed telephone numbers, tel URIs MUST NOT use spaces in visual separators to avoid overspeeding.

+2


source


Don't use a hyperlink. Use microdata. Mobile phones recognize that it is a phone number and allow it to be clicked, but this will not affect regular web browsers.

<div class="vcard">
<div class="tel">
    12345555555
</div>

      

See: fooobar.com/questions/375414 / ...

-3


source







All Articles