Jess
Jess

Reputation: 429

Html & JavaScript validation problem: "Element script is missing required attribute src"

While validating this snipit:

<script type="text/javascript" charset="utf-8">
    /* <![CDATA[ */             
    jQuery.post('http://domain.com/dev/wp-admin/admin-ajax.php', {action: 'wpp_update', token: '2e85204387', id: 214});
    /* ]]> */

</script>

I am getting the validation error: "Element script is missing required attribute src."

The page has an HTML5 doctype and is encoded as utf-8.

Upvotes: 1

Views: 2830

Answers (2)

HBlend
HBlend

Reputation: 555

Try moving the charset out of the 'script' tag and into a 'meta' tag. Charset is no longer supported as part of script in HTML5. Also note 'type' is no longer required.

Also you can remove the /* <![CDATA[ * / open and close.

See this link for a good example of handling character encoding. See this link for info on what attributes are supported in HTML5.

Upvotes: 0

Emmett
Emmett

Reputation: 14327

http://www.w3schools.com/TAGS/att_script_charset.asp

The charset attribute specifies the character encoding used in an external script file (referred to by the src attribute).

In other words, you shouldn't be using the charset attribute here, since you're not using an external script file. If you remove it, it'll validate.

Upvotes: 3

Related Questions