Solved

Correct way to declare javaScript in html5

Posted on 2013-11-22
8
263 Views
Last Modified: 2013-11-22
When validating my page the validator says the declaring the language is no longer necessary
What i have now
<script type="text/javascript" src="JavaScriptJS/NewFooter.js"></script>

Is this correct: ?
<script  src="JavaScriptJS/NewFooter.js"></script>
0
Comment
Question by:isnoend2001
  • 5
  • 3
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39670713
Assume you are using HTML5...
type="text/javascript" - is not necessary for HTML5, it is assumed to be JavaScript

Though I have never had W3C complain about my pages where it still exists...
0
 

Author Comment

by:isnoend2001
ID: 39670729
W3C warns me not an error
It states it is not necessary.
Just want to be sure removing it from my tags. I am writing it correctly
0
 
LVL 58

Expert Comment

by:Gary
ID: 39670733
Yep, not necessary.
Just checked it again with an HTML5 page and I don't even get a warning about it. Weird you are.
Are you using http://validator.w3.org/
0
 

Author Comment

by:isnoend2001
ID: 39670751
looks as though they have removed the warning  http://validator.w3.org/
I was getting them last month.
Been using another validator cause  http://validator.w3.org was down last week
http://www.onlinewebcheck.com/check.php
It still gives this:
Use the "type" attribute instead, and remove the "language" attribute (which is deprecated in HTML 4.01 and obsolete in HTML5). More: This "script" tag uses one or more entirely obsolete (in HTML5) attributes which must not be used in HTML5 documents. The HTML5 obsolete attributes for "script" include: "event", "for", and "language". This message is displayed up to 5 times.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:isnoend2001
ID: 39670762
This validator(http://www.onlinewebcheck.com/check.php) also gives this warning:
Warning:
The natural primary language is not specified. It is highly recommended that the "lang" and/or "xml:lang" (for XHTML) attributes be used with the "html" element to specify the primary language. For example, use lang="en" for English or lang="fr" for French. Specifying the language assists braille translation software, speech synthesizers, translation software, and has other benefits.

<html>
So now i am adding this:
<html lang="en">
0
 

Author Comment

by:isnoend2001
ID: 39670806
From  http://validator.w3.org

Warning Line 33, Column 74: The language attribute on the script element is obsolete. You can safely omit it.

…ript type="text/javascript" language="javascript" src="js/lytebox.js"></script>
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39670827
Well anyway it is not required but it is not an invalid attribute, So you can just use
<script  src="JavaScriptJS/NewFooter.js"></script>
0
 

Author Closing Comment

by:isnoend2001
ID: 39670834
Thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

"I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now