rams
rams

Reputation: 359

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.

Upvotes: 0

Views: 2126

Answers (3)

richard4s
richard4s

Reputation: 138

The <a> tag in HTML does not take in an attribute of src. The href attribute should work just fine in your code. Your code should look like:

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

But if you say the reason why you need a src attribute in your code maybe there's a workaround otherwise just use JavaScript for any kind of DOM manipulation.

Upvotes: 1

Ismail Farooq
Ismail Farooq

Reputation: 6827

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>

Upvotes: 3

user8158111
user8158111

Reputation:

src can't be used with <a> tag. To see the list for its support, click here.

Upvotes: 1

Related Questions