- HTML JavaScript
- Example
- My First JavaScript
- The HTML Tag
- Example
- A Taste of JavaScript
- Example
- Example
- Example
- The HTML Tag
- Example
- HTML Exercises
- HTML Script Tags
- W3Schools Spaces
- My Learning
- Track your progress with our free «My Learning» program.
- Log in to your account, and start earning points!
- Become a PRO User
- And unlock powerful features:
- Color Picker
- W3Schools’ famous color picker:
- Code Game
- Help the Lynx collect pine cones!
- Exercises and Quizzes
- Test your skills!
- Web Templates
- Browse our selection of free responsive HTML Templates
- Kickstart your career
- How To Section
- Code snippets for HTML, CSS and JavaScript
- Report Error
- Thank You For Helping Us!
- Using a JavaScript Library
- London
- Paris
- Tokyo
- Congratulations!
- COLOR PICKER
- Report Error
- Thank You For Helping Us!
HTML JavaScript
JavaScript makes HTML pages more dynamic and interactive.
Example
My First JavaScript
The HTML Tag
The HTML tag is used to define a client-side script (JavaScript).
The element either contains script statements, or it points to an external script file through the src attribute.
Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.
To select an HTML element, JavaScript most often uses the document.getElementById() method.
This JavaScript example writes «Hello JavaScript!» into an HTML element with >
Example
Tip: You can learn much more about JavaScript in our JavaScript Tutorial.
A Taste of JavaScript
Here are some examples of what JavaScript can do:
Example
JavaScript can change content:
Example
JavaScript can change styles:
document.getElementById(«demo»).style.fontSize = «25px»;
document.getElementById(«demo»).style.color = «red»;
document.getElementById(«demo»).style.backgroundColor = «yellow»;
Example
JavaScript can change attributes:
The HTML Tag
The HTML tag defines an alternate content to be displayed to users that have disabled scripts in their browser or have a browser that doesn’t support scripts:
Example
HTML Exercises
HTML Script Tags
Tag | Description |
---|---|
Defines a client-side script | |
Defines an alternate content for users that do not support client-side scripts |
For a complete list of all available HTML tags, visit our HTML Tag Reference.
W3Schools Spaces
Learn More
My Learning
Track your progress with our free «My Learning» program.
Log in to your account, and start earning points!
Become a PRO User
And unlock powerful features:
- Browse W3Schools without ads
- Website hosting (Includes Spaces PRO)
- Access to our HTML Video Tutorial
Color Picker
W3Schools’ famous color picker:
Code Game
Help the Lynx collect pine cones!
Exercises and Quizzes
Test your skills!
Web Templates
Browse our selection of free responsive HTML Templates
Kickstart your career
Get certified by completing a course
How To Section
Code snippets for HTML, CSS and JavaScript
For example, how to create a slideshow:
Follow us:
Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
Thank You For Helping Us!
Your message has been sent to W3Schools.
Top Tutorials
Top References
Top Examples
Get Certified
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.
Using a JavaScript Library
London
London is the capital city of England.
Paris
Paris is the capital of France.
Tokyo
Tokyo is the capital of Japan.
Congratulations!
You have just learned the basics of using a JavaScript library.
COLOR PICKER
Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
Thank You For Helping Us!
Your message has been sent to W3Schools.
Top Tutorials
Top References
Top Examples
Get Certified
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.