Kids Web Dev
← Road to Web Dev

Web Dev setup · 2 of 2

Build your first HTML, CSS and JavaScript project

Build Signal Station, a small page with a message and a button. Follow the local steps to make and link three files, or open the same project in Coding Studio to read, edit and run it in the browser.

Use Coding Studio in the app

  1. Choose Open project in Coding Studio. The HTML, CSS and JS tabs contain the example. Open each tab as you read the file explanations below.

  2. Choose Run in Studio. In the preview, choose Send signal. Edit the message in the JS tab if you want to see how saving and running a change works. Choose Run again to refresh the preview.

    What you should see · A blue button on a light blue page. After you click the button, the message reads Signal received!

  3. Studio puts the three tabs together for its preview. The HTML tab uses the page content inside the body. When you make files on your own computer, index.html links the stylesheet and script using the lines shown below.

Make the three local files

  1. In VS Code, open the signal-station folder. Use New File in Explorer to make any missing files below. Keep all three in that same folder, with these exact names.

    signal-station/
      index.html
      styles.css
      script.js
  2. You can also download the completed starter ZIP from this lesson. In Windows File Explorer, right-click it and choose Extract All. On Mac, double-click it in Finder. In VS Code, open the extracted folder containing index.html.

index.html · structure and links

  1. Open index.html and type or paste the code below. Save the file. The heading, message and button are the visible content.

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Signal Station</title>
      <link rel="stylesheet" href="styles.css">
      <script src="script.js" defer></script>
    </head>
    <body>
      <main>
        <h1>Signal Station</h1>
        <p id="message" role="status">The station is waiting.</p>
        <button id="send" type="button">Send signal</button>
      </main>
    </body>
    </html>
  2. The line with link tells the browser to load styles.css. The line with script tells it to load script.js. The href and src values are file names relative to index.html. Because the files share a folder, their names are enough.

    <link rel="stylesheet" href="styles.css">
    <script src="script.js" defer></script>
  3. The defer attribute tells the browser to run script.js after it has read the HTML. That way the script can find the message and the button.

styles.css · the way the page looks

  1. Open styles.css, add the code below, and save it. The body rule sets the page background and font. The main rule styles the white content area. The button rule styles the Send signal button.

    body {
      font-family: system-ui, sans-serif;
      background: #edf4ff;
      color: #173050;
      margin: 0;
      padding: 1rem;
    }
    
    main {
      max-width: 34rem;
      margin: 2rem auto;
      padding: 1.5rem;
      background: white;
      border-radius: 0.75rem;
    }
    
    button {
      background: #204b92;
      color: white;
      border: 0;
      border-radius: 0.35rem;
      padding: 0.65rem 1rem;
      font: inherit;
    }

script.js · what happens on a click

  1. Open script.js, add the code below, and save it. getElementById looks for id values in the HTML. The click listener waits for someone to use the button, then changes the message.

    const sendButton = document.getElementById('send');
    const message = document.getElementById('message');
    
    sendButton.addEventListener('click', () => {
      message.textContent = 'Signal received!';
    });

Open the page in a browser

  1. Save all three files. In File Explorer on Windows or Finder on Mac, open the project folder and double-click index.html. If it opens in an editor, use Open with and choose a web browser.

    What you should see · The tab title is Signal Station. The page shows a light blue background, a white card and a blue button.

  2. Click Send signal. The message changes to Signal received! When you edit a file, save it in VS Code, then return to the browser and refresh the page.

If the page looks different

  1. If the page is unstyled, compare the link in index.html with the name styles.css. Check that both files are saved in the same folder.

  2. If the button doesn’t change the message, compare the script source with script.js and the two id values with the HTML. Keep defer on the script. In Chrome or Edge, right-click the page, choose Inspect, then select Console to read the first error.

  3. If the browser displays code as text, check the full file name in VS Code. It should end in .html. To make another site, repeat this folder and file layout and give the new project its own folder.

Start Road to Web Dev → Install tools for later projects