Build a Checkout Page - Build a Checkout Page

Tell us what’s happening:

All of your input elements that aren’t a type of submit should have a label element associated with them. Keep failing this prompt. Having a hard time determining what is wrong. Used two different versions of code, neither worked, commented out the first version.

Your code so far

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>Checkout Page</title>
</head>

<body>
    <h1>Checkout</h1>
        <section>
            <h2>Your Cart</h2>
            <img src="https://cdn.freecodecamp.org/curriculum/labs/cube.jpg" alt="Rubix Cube">
        </section>
        <section>
            <h2>Payment Information</h2>
            <form>
                <div>
             <!--   <input id="card-name" name="card-name" required aria-required="true"></input>
                <label type="text" name="card-name">Card Name</label> -->
                <label for="name">Card Name
            <input type="text"id="card-name" name="card-name" required aria-required="true">  
            </label>
                </div>
                <div>
                    <!--
                <input id="card-number" name="card-number" required aria-required="true"></input>
                <label type="number" name="card-number">Card Number</label>
                -->
                <label for="number">Card Number
            <input type="number"id="card-number" name="card-number" required aria-required="true">  
            </label>
                </div>
                <div>
                    <!--
                <input id="cvv" name="cvv"></input>
                <label type="number" name="cvv">CVV</label>
                -->
                </div>
                <input type="submit"></button>
            </form>
        </section>
</body>

</html>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Build a Checkout Page - Build a Checkout Page
https://www.freecodecamp.org/learn/full-stack-developer/lab-checkout-page/build-a-checkout-page

do you know how to associate a label and an input?

I figured it out - I didn’t have the for attribute in the original code - I was assuming the name feature was going to associate the label and the input but I think they only allow for grouping?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.