Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Correct way to declare javaScript in html5

Posted on 2013-11-22
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>
Question by:isnoend2001
  • 5
  • 3
LVL 58

Expert Comment

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...

Author Comment

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
LVL 58

Expert Comment

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/
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

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
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.

Author Comment

ID: 39670762
This validator(http://www.onlinewebcheck.com/check.php) also gives this 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.

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

Author Comment

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>
LVL 58

Accepted Solution

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>

Author Closing Comment

ID: 39670834

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Place text over image using CSS 6 52
CSS: How do I override in-line styling 11 26
Are these icons a web font? 3 21
Fix a css menu for width 15 23
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…
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

828 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