codex-lv2-may-2025

Level Navigation: 1 2 3 4 Current Level: 5 6 7 8 9 10

โœ… Step 5: Build the Weather Card

Goal: Create a Bootstrap card with span elements to display weather information.


๐Ÿ“‹ What Youโ€™ll Do

  1. Add a Bootstrap card to your HTML
  2. Include span elements with specific IDs for JavaScript targeting
  3. Style the card for professional appearance

๐Ÿš€ Step-by-Step Instructions

1. Add the Weather Card

In your index.html, add this Bootstrap card inside the container div:

<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">New Orleans Weather</h5>
    <p class="card-text">
      Temperature: <span id="temp"></span>ยฐC<br>
      Wind Speed: <span id="wind"></span> km/h<br>
      Weather Code: <span id="code"></span>
    </p>
  </div>
</div>

2. Understand the Structure


๐Ÿ’ก What This Accomplishes

The Bootstrap card provides a professional, responsive container for displaying weather information. By using span elements with specific IDs, you create placeholders that JavaScript can target and update dynamically. This approach separates the structure (HTML) from the content (JavaScript), following modern web development principles and making your app look polished and professional.


๐Ÿ“š About Span Tags

A <span> tag is an inline HTML element used to mark up a part of text. Itโ€™s perfect for targeting specific text with JavaScript because you can give it an id attribute and then use functions like setText() to update just that part of the content without affecting the rest of the paragraph. ๐Ÿ“– Learn more about span tags


โœ… Check Your Work


๐Ÿ”— Navigation


Ready for the next step? Continue to Step 6: Display Weather Data


Level Navigation: 1 2 3 4 Current Level: 5 6 7 8 9 10