Survey Form - Build a Survey Form

Hello, I’m currently stuck on something very trivial (most likely has an easy fix, but I can’t seem to solve it). I would like to be able to align the “Activity x” text on the right of the checkboxes. However, I’m not sure on how to do this.

Any help is appreciated!
Screenshot 2022-08-28 22.02.11

  **Your code so far**
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans&display=swap" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="styles.css">
    </head>
    <body>
     <div>
      <h1 id="title">Survey form</h1>
      <p id="description">This is a survey to gather information.</p>
      </div>
      <form id="survey-form" action="https://www.freecodecamp.org/">
      <fieldset>  
        <label id="name-label">Enter Your Name: <input type="text" id="name" required name="name" placeholder="John Doe"></label>
        <label id="email-label">Enter Your Email: <input type="email" id="email" required name="email" placeholder="JohnDoe@gmail.com">
            </label>
            <label id="number-label">Enter Your Age (Years): <input type="number" id="age" required name="age" min="13" max="120" placeholder="18">
              </label>
<label>Select Your Gender: 
  <select placeholder="(select one)">
<option>(select one)</option>
<option>Male</option>
<option>Female</option>
<option>Non-Binary</option>
<option>Other</option>
<option>Prefer not to say..</option>
    </select>
</fieldset>

<fieldset>
<p class="which-activities">  Which of these activities did  you perform?</p>
<div class="activities">
<label><input type="checkbox" value="1"/> Swimming</label>
<label>  <input type="checkbox" value="2"/> Attending Breakfast</label>
<label>  <input type="checkbox" value="3"/> Movie Night </label>
<label>  <input type="checkbox" value="4"/> Shopped in the indoor mall </label>
<label>  <input type="checkbox" value="5"/> Went to the zoo (petting) </label>
<label>  <input type="checkbox" value="6"/> Went fishing </label>
<label>  <input type="checkbox" value="7"/> Went on a tour </label>
</div>
  
  </fieldset>



<fieldset>
  </label>
<label>Are You Happy With This Service?
<input type="radio" required name="experience" class="inline">Yes
<input type="radio" required name="experience" class="inline">No
</label>
<label id="feedback">If so, why?
<textarea id="comment" optional rows="5" cols="45" placeholder="I had a bad experience with.."></textarea>
  </label>

            </fieldset>

<input type="submit" value="Submit" />

            

        </form>
      </body>
      </html>
css
/* file: styles.css */
*{
  margin:0;
  padding:0;

}

body{
  background-color:#301934;
  color:#F9F6EE;
  width:100%;
  height:100vh;
  font-family: 'Josefin Sans', sans-serif;
  font-size:16px;



}
#title, p{
  margin:1em auto;
  text-align:center;
  margin-top:1em;
  margin-bottom:0.5em;
}
p{
font-size:18px;
}
form{
  width:75vh;
  max-width:600px;
  min-width:300px;
  margin: 0 auto;
}
label {
display:block;
margin-top:0.5em auto;
text-align:center;

}
fieldset{
  border:0px;
  padding:2rem 0px;
}

input, select{
  margin:10px 0 0 0;
  min-height:2em;
  width:100%;
  margin-bottom:1em;
}
.inline{
  width:unset;
  vertical-align:middle;
  margin: 0px 5px;
}
fieldset{
  border-bottom:1px solid grey ;
  
}
fieldset:last-of-type{
  border:0px;
}


#feedback{
  margin-top:10px;
}

#feedback{
  display:block;
  margin-bottom:em;
}

textarea{
  padding-top:0.3em;
  margin-top:20px;
  margin: 0px auto;
  min-height:em;
}

textarea, input, select{
  border:0px;
  background-color:#213868;
  color:#fff;
}

input[type="submit"]{
  width:10em;
  margin: 0 auto;
  display:block;
  background-color:#a7a6ba;
  border:0px;
}

#comment{
  margin-top:1em;
} 

input[type="checkbox"]{
  width:unset;
  vertical-align:middle;
  
}

#cb{
  display:block;

}

.activities{
position:relative;
left:-8.25em;
  
}


/* NOTES:

- complete the styling for the submit button
- add a bottom line
- add more space at the bottom (below the submit button)
- get rid of the black border
*/```





      **Your browser information:**

User Agent is: <code>Mozilla/5.0 (X11; CrOS x86_64 14909.100.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36</code>

**Challenge:**  Survey Form - Build a Survey Form

**Link to the challenge:**
https://www.freecodecamp.org/learn/2022/responsive-web-design/build-a-survey-form-project/build-a-survey-form

Check step 46 of the tutorial: https://www.freecodecamp.org/learn/2022/responsive-web-design/learn-html-forms-by-building-a-registration-form/step-46

After your inputs/labels are in display: block, give the inputs a “width: unset” to make them stay in the same line, close to each other.

1 Like

Heyy thank you so much!

However, I have discovered another little brick wall that I’ve encountered.
How would I go about positioning them (the checkboxes and activity text) to the left of the form instead of the middle?
I tried “float:left;” but that only moved a little bit.

edit:making the problem clearer.
Screenshot 2022-08-28 22.55.07

I may be mistaken… I think they should be on the left by default and maybe there is something applying the central align to them?

Would you mind sharing your current HTML and CSS code again?

type your code between the ''' ''' to avoid being formatted

My html:

‘’'

Survey form

This is a survey to gather information.

Enter Your Name: Enter Your Email: Enter Your Age (Years): Select Your Gender:

Which of these activities did you perform?

Swimming Attending Breakfast Movie Night Shopped in the indoor mall Went to the zoo (petting) Went fishing Went on a tour
Are You Happy With This Service? Yes No If so, why?
        </fieldset>
    </form>
  </body>
  </html>'''

My CSS:
‘’'*{
margin:0;
padding:0;

}

body{
background-color:#301934;
color:#F9F6EE;
width:100%;
height:100vh;
font-family: ‘Josefin Sans’, sans-serif;
font-size:16px;

}
#title, p{
margin:1em auto;
text-align:center;
margin-top:1em;
margin-bottom:0.5em;
}
p{
font-size:18px;
}
form{
width:75vh;
max-width:600px;
min-width:300px;
margin: 0 auto;
}
label {
display:block;
margin-top:0.5em auto;
text-align:center;

}
fieldset{
border:0px;
padding:2rem 0px;
}

input, select{
margin:10px 0 0 0;
min-height:2em;
width:100%;
margin-bottom:1em;
}
.inline{
width:unset;
vertical-align:middle;
margin: 0px 5px;
}
fieldset{
border-bottom:1px solid grey ;

}
fieldset:last-of-type{
border:0px;
}

#feedback{
margin-top:10px;
}

#feedback{
display:block;
margin-bottom:em;
}

textarea{
padding-top:0.3em;
margin-top:20px;
margin: 0px auto;
min-height:em;
}

textarea, input, select{
border:0px;
background-color:#213868;
color:#fff;
}

input[type=“submit”]{
width:10em;
margin: 0 auto;
display:block;
background-color:#a7a6ba;
border:0px;
}

#comment{
margin-top:1em;
}

input[type=“checkbox”]{
width:unset;
vertical-align:middle;

}

#cb{
display:block;

}

.activities{
position:relative;
left:-8.25em;

}

/* NOTES:

  • complete the styling for the submit button
  • add a bottom line
  • add more space at the bottom (below the submit button)
  • get rid of the black border
    */‘’’

My HTML:
‘’’

Survey form

This is a survey to gather information.

Enter Your Name: Enter Your Email: Enter Your Age (Years): Select Your Gender:

Which of these activities did you perform?

Swimming Attending Breakfast Movie Night Shopped in the indoor mall Went to the zoo (petting) Went fishing Went on a tour
Are You Happy With This Service? Yes No If so, why?
        </fieldset>
    </form>
  </body>
  </html>

‘’’

My CSS:
‘’’
*{
margin:0;
padding:0;

}

body{
background-color:#301934;
color:#F9F6EE;
width:100%;
height:100vh;
font-family: ‘Josefin Sans’, sans-serif;
font-size:16px;

}
#title, p{
margin:1em auto;
text-align:center;
margin-top:1em;
margin-bottom:0.5em;
}
p{
font-size:18px;
}
form{
width:75vh;
max-width:600px;
min-width:300px;
margin: 0 auto;
}
label {
display:block;
margin-top:0.5em auto;
text-align:center;

}
fieldset{
border:0px;
padding:2rem 0px;
}

input, select{
margin:10px 0 0 0;
min-height:2em;
width:100%;
margin-bottom:1em;
}
.inline{
width:unset;
vertical-align:middle;
margin: 0px 5px;
}
fieldset{
border-bottom:1px solid grey ;

}
fieldset:last-of-type{
border:0px;
}

#feedback{
margin-top:10px;
}

#feedback{
display:block;
margin-bottom:em;
}

textarea{
padding-top:0.3em;
margin-top:20px;
margin: 0px auto;
min-height:em;
}

textarea, input, select{
border:0px;
background-color:#213868;
color:#fff;
}

input[type=“submit”]{
width:10em;
margin: 0 auto;
display:block;
background-color:#a7a6ba;
border:0px;
}

#comment{
margin-top:1em;
}

input[type=“checkbox”]{
width:unset;
vertical-align:middle;

}

#cb{
display:block;

}

.activities{
position:relative;
left:-8.25em;

}

/* NOTES:

  • complete the styling for the submit button
  • add a bottom line
  • add more space at the bottom (below the submit button)
  • get rid of the black border
    */
    ‘’’

Hey! For some reason when i attempt to include my code in ‘’’ ‘’’ it triggers the spam filter. I will just edit the posts html and css instead.

You’re applying a “text-align: center” to them:

label {
display:block;
margin-top:0.5em auto;
text-align:center;
}

Remove that from the “label” selector; instead, create a class and class selector to apply that only to the elements you want;

You’ll see that by removing the text-align: center your checkboxes will go wild to the left, that’s something you need to fix, visually speaking;

EDIT: Don’t be afraid or ashamed of going back to the tutorials and copying what’s being done, practice makes perfect. The more you practice, even if you’re just copying or doing what a tutorial tells you, slowly you’ll understand how things are connected.

Thank you!!! You’re a legend!

All my (current) issues have been solved and I will take your tip (about looking at tutorials) - Thanks once again and I wish you the best :smiley:

1 Like

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