Skip to content

Add interactive examples to What Is JavaScript, and How Does It Work with HTML and CSS lesson #63169

@jdwilkin4

Description

@jdwilkin4

Here is the file

https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lecture-introduction-to-javascript/672d26385dbe73203c4dac81.md

Here is the new version

---
id: 672d26385dbe73203c4dac81
title: What Is JavaScript, and How Does It Work with HTML and CSS?
challengeType: 19
dashedName: what-is-javascript
---

# --interactive--

JavaScript is a powerful programming language that brings interactivity and dynamic behavior to websites.

While HTML and CSS are markup languages used to structure content and style elements on a page, JavaScript goes beyond those by enabling more complex functionality, such as handling user input, animating elements, and even building full web applications.

For example, when you click a button, submit a form, or hover over a menu, JavaScript determines how the page behaves.

Here's an example of how these three work together:

:::interactive_editor

```html
<!DOCTYPE html>
<html>
<head>
  <style>
    h1 {
      color: green;
    }
  </style>
</head>
<body>
  <h1>Hello, World!</h1>
  <button onclick="alert('Button clicked!')">Click me</button>
</body>
</html>
```

:::

In this example, HTML is used to define the content: a heading (an `h1` element) and a button (the `button` element).

CSS is used to apply styles to the heading, such as making the text green. JavaScript is used to display an alert message when the button is clicked.

To sum up, HTML provides structure, CSS adds styling, and JavaScript enables behavior, creating a complete and interactive web experience.

# --questions--

## --text--

What role does JavaScript play in web development compared to HTML and CSS?

## --answers--

JavaScript provides structure to the webpage and ensures that your code is free of errors.

### --feedback--

Consider what happens when a user interacts with a web page, such as clicking a button.

---

JavaScript provides the styles for the web page and automatically formats your code.

### --feedback--

Consider what happens when a user interacts with a web page, such as clicking a button.

---

JavaScript provides interactive functionality and dynamic behavior for the web page.

---

JavaScript is only used to create advanced animations for web applications.

### --feedback--

Consider what happens when a user interacts with a web page, such as clicking a button.

## --video-solution--

3

## --text--

How does JavaScript typically interact with HTML and CSS on a webpage?

## --answers--

JavaScript adds more styles to the CSS file and more elements to the HTML file.

### --feedback--

Think about how JavaScript can change the webpage's content or styles without needing a page reload.

---

JavaScript creates a new version of HTML for the page so your HTML code will run faster.

### --feedback--

Think about how JavaScript can change the webpage's content or styles without needing a page reload.

---

JavaScript interacts with the page to change content and styles dynamically.

---

JavaScript only works in the backend and is rarely used in the frontend.

### --feedback--

Think about how JavaScript can change the webpage's content or styles without needing a page reload.

## --video-solution--

3

## --text--

Which of the following is true about the relationship between JavaScript, HTML, and CSS?

## --answers--

HTML and CSS are programming languages, while JavaScript is a markup language.

### --feedback--

Consider which languages define content and style, and which language handles functionality.

---

HTML and CSS are markup languages, while JavaScript is a programming language.

---

JavaScript can replace HTML and CSS.

### --feedback--

Consider which languages define content and style, and which language handles functionality.

---

JavaScript does not work with HTML and CSS.

### --feedback--

Consider which languages define content and style, and which language handles functionality.

## --video-solution--

2

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedOpen for all. You do not need permission to work on these.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions