Search code examples
htmlfacebookw3c-validation

HTML validator error "Attribute src not allowed on element a"


While running HTML validator on my HTML code, the following error is encountered:

Error: Attribute src not allowed on element a at this point.

The code snippet where the error occurs is:

<a    class="fb-xfbml-parse-ignore" 
      target="_blank" 
       href='https://www.facebook.com/sharer/sharer.php?u=https://testingsite.com/j8h' 
       src="sdkTesting"
       title="Facebook">

How can I fix? Some internet pages tells me go with data-src rather than src attribute, while there is no information on Facebook regarding this.


Solution

  • Simply Use data- with all attr for example

    <a class="fb-xfbml-parse-ignore"
    target="_blank"
    data-href='https://www.facebook.com/sharer/sharer.php?u=https://testingsite.com/j8h'
    data-src="sdkTesting"
    title="Facebook"></a>