← Taso 1 – Rakentaja

Oppitunti 4/12 ⏱ 25 minuuttia

Linkit ja toinen sivu

Verkkosivusi ei ole enää vain yksi sivu. Rakennat toisen ja yhdistät ne linkeillä.

Näytän sinulle: linkki

Linkki – klikattava asia joka vie jonnekin muualle – tehdään <a>-tagilla:

<!-- A link to another page on your own website -->
<a href="lunch-menu.html">Lunch Menu</a>

<!-- A link out to somewhere else on the internet -->
<a href="https://www.si.edu">Our favorite museum's website</a>

Toinen sivu

Verkkosivullasi on toistaiseksi vain index.html. Lisätään toinen sivu – se on vain uusi tiedosto samassa kansiossa:

  1. VS Codessa luo uusi tiedosto. Nimeä se projektisi mukaan, kuten lunch-menu.html, about-me.html, trips.html tai roster.html. Taas pienet kirjaimet, ei välilyöntejä tai ääkkösiä.

  2. Liitä koko sivun luuranko (sama kuin oppitunnilla 1) ja anna sille oma <title>, <h1> ja sisältöä.

  3. Yhdistä sivut linkeillä: index.html:ssä lisää linkki uudelle sivulle, ja uudella sivulla linkki takaisin – jotain kuten <a href="index.html">Back home</a>.

Nyt sinun vuorosi 💪

Luo toinen sivu ja linkitä molemmat sivut yhteen. Tee vähintään yksi linkki myös internetin ulkopuolelle.

🏫 Koulun sivu – ratkaisu (lunch-menu.html)
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Lunch Menu – Riverside Elementary</title>
  </head>
  <body>
    <h1>This Week's Lunch Menu</h1>
    <ul>
      <li>Monday: tomato soup with pasta</li>
      <li>Tuesday: chicken with rice</li>
      <li>Wednesday: pancakes with syrup 🎉</li>
      <li>Thursday: beef stew with dumplings</li>
      <li>Friday: fish and potatoes</li>
    </ul>
    <p><a href="index.html">← Back to the homepage</a></p>
  </body>
</html>

Ja index.html:ssä lisää:

<p><a href="lunch-menu.html">Check out the lunch menu</a></p>
🙋 Henkilökohtainen sivu – ratkaisu (about-me.html)
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>More About Me – Jake</title>
  </head>
  <body>
    <h1>More About Me</h1>
    <p>I'm in 4th grade, I have a dog named Rocky, and I collect soccer cards.</p>
    <p>My favorite thing to listen to is <a href="https://www.youtube.com">music on YouTube</a>.</p>
    <p><a href="index.html">← Back home</a></p>
  </body>
</html>
🌍 Matkapäiväkirja – ratkaisu (trips.html)
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>All Trips – Where We've Been</title>
  </head>
  <body>
    <h1>All Our Trips</h1>
    <ol>
      <li>The mountains – a ridge hike</li>
      <li>Greece – island hopping</li>
      <li>Washington, D.C. – museums and monuments</li>
    </ol>
    <p>We plan our routes with <a href="https://maps.google.com">Google Maps</a>.</p>
    <p><a href="index.html">← Back to the homepage</a></p>
  </body>
</html>
⚽ Seuran sivu – ratkaisu (roster.html)
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Roster – Riverside Eagles FC</title>
  </head>
  <body>
    <h1>Team Roster</h1>
    <ul>
      <li>Jake – goalkeeper (captain)</li>
      <li>Matt – defense</li>
      <li>Owen – midfield</li>
      <li>Tom – forward</li>
    </ul>
    <p>Check the league schedule at <a href="https://www.ussoccer.com">ussoccer.com</a>.</p>
    <p><a href="index.html">← Back to the homepage</a></p>
  </body>
</html>

Tarkista itse: Klikkaat linkkiä etusivulla → toinen sivu avautuu. Klikkaat “Back” → olet taas kotona. Verkkosivullasi on nyt ensimmäistä kertaa useampi sivu!

Mitä opit tästä oppitunnista