SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
Lesson 24 of 30

HTML JavaScript

2 min read · Free · No login needed

JavaScript is the programming language of the web. HTML builds the page, CSS styles it, and JavaScript makes it do things: respond to clicks, check a form before it is sent, show and hide content, load new data without refreshing the page.

Adding JavaScript to a page

Write it inside a <script> tag, usually just before the closing </body> so the page content loads first. Or keep it in a separate .js file and link it: <script src="app.js"></script>. The separate-file way is better for real sites — one script file can serve every page.

What JavaScript can do

  • Change content: document.getElementById("demo").innerHTML = "Hello!"; replaces the text inside an element.
  • Change styles: element.style.color = "red"; recolours it.
  • React to events: run code when a button is clicked, a form is submitted, or a key is pressed.
  • Check input: make sure an email looks like an email before the form is sent.

Your first script

The example below has a button. When you click it, JavaScript changes the text of a paragraph. It is only three lines — but it is the same idea behind every interactive feature on the web, from a "like" button to a full quiz timer.

Tip: Open your browser's developer tools (F12) and click the Console tab. Any error in your JavaScript appears there, with the line number. It is the first place to look when a script does not work.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
</head>
<body>

<p id="demo">Click the button to change this text.</p>
<button onclick="document.getElementById('demo').innerHTML = 'Hello, JavaScript!'">Click Me</button>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML JavaScript
Try it yourself: copy the code above into a file named test.html, open it in your browser, and change the text to see what happens. That is how you learn — by changing things and watching the result.
Get certified — just ₹10

Finish all 30 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test
Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Advanced Cyber Security Industrial Training
₹5,000
View
Summer Industrial Training in MERN Stack 2026
₹3,000
View
Master Python + AI Skills in 30 Days
₹499
View
Browse all courses
HTML — Lessons
1. HTML Introduction 2. HTML Editors 3. HTML Basic 4. HTML Elements 5. HTML Attributes 6. HTML Headings 7. HTML Paragraphs 8. HTML Styles 9. HTML Formatting 10. HTML Comments 11. HTML Colors 12. HTML CSS 13. HTML Links 14. HTML Images 15. HTML Favicon 16. HTML Page Title 17. HTML Tables 18. HTML Lists 19. HTML Block and Inline Elements 20. HTML Div 21. HTML Classes 22. HTML Id 23. HTML Iframes 24. HTML JavaScript 25. HTML File Paths 26. HTML Head 27. HTML Layout 28. HTML Responsive 29. HTML Semantics 30. HTML Forms
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🛡️ 7-Day Money-Back Guarantee
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Download karne ke liye login karo. Login ke baad yahi page pe rahoge!

Naya ho? Register karo →