From eb59d7e3e268970e505921b9299294e8847c47b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giftea=20=E2=98=95?= Date: Thu, 9 Oct 2025 22:58:12 +0100 Subject: [PATCH] feat(curriculum): Add interactive example to script element lesson (#62647) --- .../670838b10ee87a18e5faff62.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/curriculum/challenges/english/blocks/lecture-html-fundamentals/670838b10ee87a18e5faff62.md b/curriculum/challenges/english/blocks/lecture-html-fundamentals/670838b10ee87a18e5faff62.md index 4c79a03e90d..7a8cfe15ee4 100644 --- a/curriculum/challenges/english/blocks/lecture-html-fundamentals/670838b10ee87a18e5faff62.md +++ b/curriculum/challenges/english/blocks/lecture-html-fundamentals/670838b10ee87a18e5faff62.md @@ -5,19 +5,23 @@ challengeType: 19 dashedName: what-is-the-role-of-the-script-element-in-html --- -# --description-- +# --interactive-- -The `script` element is used to embed executable code. Most developers will use this to execute JavaScript code. JavaScript is used to add interactivity to your web pages. Common examples of using JavaScript include interactive games, image sliders, and dynamic forms that validate user input in real-time. Here is an example of using the `script` element in an HTML document: +The `script` element is used to embed executable code. Most developers will use this to execute JavaScript code. JavaScript is used to add interactivity to your web pages. Common examples of using JavaScript include interactive games, image sliders, and dynamic forms that validate user input in real-time. + +Here is an example of using the `script` element in an HTML document. Remove the `//` from in front of the `alert("Welcome to freeCodeCamp");` and you should see an alert pop up. + +:::interactive_editor ```html ``` -In this example, we have an `alert` to display the message `Welcome to freeCodeCamp.` When the page first loads, the alert will pop up. Then the user can click on the OK button to dismiss the message. +::: While you can technically write all of your JavaScript code inside the `script` tags, it is considered best practice to link to an external JavaScript file instead. Here is an example of using the `script` element to link to an external JavaScript file: