Free Ebook cover Complete HTML Course

Complete HTML Course

4.38

(8)

37 pages

Introduction to JavaScript in HTML

Capítulo 12

Estimated reading time: 1 minutes

Audio Icon

Listen in audio

0:00 / 0:00

JavaScript is a programming language that allows you to create interactivity on a web page. It can be used in conjunction with HTML and CSS to create dynamic and lively pages.

To use JavaScript in an HTML page, it is necessary to enclose the code in a <script> tag. This tag can be placed in the header or body of the page, depending on the need.

For example, to create an alert that appears when the user clicks a button, JavaScript code can be written as follows:

<button onclick="alert('Hello world!')">Click here</button>

In this case, the <button> tag is used to create a button on the page. The onclick property is used to indicate that an action should be performed when the button is clicked. In this case, the action is an alert with the message "Hello world!".

In addition to creating alerts, JavaScript can be used to validate forms, create animations, manipulate page elements, and much more. To learn more about JavaScript, it is recommended to study the language's official documentation and practice creating small projects.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

In summary, JavaScript is an essential programming language for creating interactive and dynamic web pages. By using JavaScript in conjunction with HTML and CSS, you can create amazing designs that go beyond the basics.

Now answer the exercise about the content:

_What is the tag used to include the JavaScript code in an HTML page?

You are right! Congratulations, now go to the next page

You missed! Try again.

The tag used to include JavaScript code in an HTML page is the <script> tag. This tag can be placed in the <head> or <body> of the HTML page.

Next chapter

Handling HTML elements with JavaScript

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.