Survey Form - Build a Survey Form

Tell us what’s happening:

Please help! My html code has successfully passed, but i can’t align radio and checkbox buttons.

Your code so far

<!-- file: index.html -->
 <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Traveling Survey Form</title> 
  <link rel="stylesheet" href="styles.css">
  </head>
  <body>
    <h1 id="title">Traveling Survey Form</h1>
    <p id="description">Please fill out this Survey Form about your traveling preferrences.</p>
    <form method="post"  id="survey-form"> 
      <fieldset><legend>Personal Information</legend>
        <label for="name" id="name-label">Enter your name<input id="name" type="text" name="your-name" placeholder="Enter your name" required> 
        </label>
        <label for="email" id="email-label">Email<input type="email" id="email" name="email" placeholder="Enter your email" required> 
        </label>
        <label for="age" id="number-label">Age<input type="number" id="number" name="age" min="13" max="120" placeholder="Enter your age" required> 
        </label>
        <label for="location">What is your location?
          <select id="dropdown">
            <option value="">(select one) </option>
            <option value="1">United States</option>
            <option value="2">Europe</option>
            <option value="3">Middle East</option>
            <option value="4">Asia</option>
            <option value="5">Africa</option>
            <option value="6">India</option>
            </select>
           </label>
      </fieldset>
      <fieldset>
        <legend >Do you like to travel</legend>
        <label for="I-like-to-travel"> I like to travel <input type="radio" id="i-like-to-travel" name="do-you-like-to-travel"  value="0" class="inline" checked> 
        </label>
        <label for="not-sure"> Not sure <input type="radio" id="not-sure" name="do-you-like-to-travel" value="1" class="do-you-like-to-travel"> 
        </label>
        <label for="i-like-to-stay-home">I like to stay home<input type="radio" id="i-like-to-stay-home" name="do-you-like-to-travel" value="2" class="inline">
        </label>
      </fieldset>
      <fieldset>
        <label for="favorite-activity">What is your favourite activity at your travel destination?
          <select id="favorite-activity" name="favorite-activity">
          <option value="">(Choose one) </option>
          <option value="1">Try local food</option>
          <option value="2">Hiking</option>
          <option value="3">Relaxing</option>
          <option value="4">Explore</option>
          </select>
          </label>
      </fieldset>
      <fieldset>
        <legend>Ho do you like to travel (check all that apply)</legend>
        <label>By Airplane<input type="checkbox" value="by-airplane"> 
        </label>
        <label>By Train <input type="checkbox" value="by-train" > 
        </label>
        <label>By Bus<input type="checkbox" value="by-bus"> 
        </label>
        <label>By Car<input type="checkbox" value="by-car"> 
        </label>
        <label>By Bicycle<input type="checkbox" value="by-bicycle"> 
        </label>
        <label>By Feet<input type="checkbox" value="by-feet"> 
        </label>
        <legend>Please share your traveling experience with us</legend>
        <textarea id="experience" name="experience" rows="5" cols="50" placeholder="Share your experience here..."></textarea>
        </fieldset>
      <input type="submit" value="submit" id="submit">
    </form>

  </body>
  </html>
/* file: styles.css */
body {
  width:100%;
  height: 100vh;
  margin: 0;
  background-color: #E0E4EE;
  font-family: Tahoma;
  font-size: 16px;
}
h1, p {
  margin: 1em auto;
  text-align: center;
}
form {
width: 60vw;
max-width: 500px;
min-width: 300px;
margin: 0 auto;
padding-bottom: 2em;
}
fieldset {
  border: none;
  padding: 2rem 0;
  border-bottom: 3px solid #a7a7a7;
}
fieldset:last-of-type {
  border-bottom: none;
}
label {
  display: block;
  margin: 0.5rem 0;
  
}
input, textarea, select {
  margin: 10px 0 0 0;
  width: 100%;
}
input, textarea {
  border: 1px solid #777777;
  
}
.inline {
  width: unset;
  margin: 0 0.5em 0 0;
  display: inline;
}
input[type="submit"]{
  display: block;
  width: 60%;
  margin: 1em auto;
  height: 2em;
  font-size: 1.1rem;
  min-width: 300px;
}
input[type="radio"] {
  display: inline;
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Survey Form - Build a Survey Form

Please post your code

I’m not sure how to, I thought it will do so automatically

I would use copy and paste, myself

Hi @EmilD

Use the following method to post code to the forum:

  1. On a separate line type three back ticks.
  2. On a separate line paste your code.
  3. On the last line type three back ticks. Here is a single back tick `

Happy coding

1 Like

Here is a post from yesterday you may find helpful.

Survey Form - Build a Survey Form - HTML-CSS - The freeCodeCamp Forum

If you are still stuck, reach out to the forum.

Happy coding

I copied and pasted it, on my end i can see it, but not sure if anyone else can see it here

Thank you very much, i started the survey form all over, will try to design my code better this time

1 Like

Tell us what’s happening:

Please help me with my CSS or HTML code, I’m not sure which one is an issue, my HTML code passed the test, but my radio buttons and checkbox buttons are not aligned with text.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="styles.css">
    <title>Traveling Survey Form</title>
  </head>
  <body>
    <h1 id="title">
      Traveling Survey Form
    </h1>
    <p id="description"> 
      Please complete this survey about your traveling habits
    </p>
<form id="survey-form">
  <fieldset>
<legend>
  Personal Information
</legend>
<label for="name" id="name-label">
  Name (Required)
  <input type="text" id="name" placeholder="Enter your name" required>
</label>
<label for="email" id="email-label">
  Email (Required)
  <input type="email" id="email" placeholder="enter your email" required>
</label>
<label for="age" id="number-label">
  Age
  <input type="number" id="number" min="16" max="100" placeholder="Enter your age">
  </label>
<label for="location" id="current-location">
  Your current location
  <select id="dropdown" name="location">
    <option value="locatio">Select one</option>
    <option value="locatio">United States</option>
    <option value="locatio">Europe</option>
    <option value="locatio">Middle East</option>
    <option value="locatio">Asia</option>
    <option value="locatio">Africa</option>
    <option value="locatio">India</option>
  </select>
</label>
</fieldset>
<fieldset>
  <label for="travel" id="travel">
    Do you like to travel?
  </label>
  <input type="radio" name="travel" value="yes" checked> Yes
  <input type="radio" name="travel" value="no"> No
  <input type="radio" name="travel" value="not-sure"> Not sure 
</fieldset>
<fieldset>
  <label for="destination" id="destination">What is your favourite destination?</label>
  <select id="dropdown">
    <option value="destination">Select one</option>
    <option value="destination">United States</option>
    <option value="destination">Europe</option>
    <option value="destination">Middle East</option>
    <option value="destination">Asia</option>
    <option value="destination">Africa</option>
    <option value="destination">India</option>
    <option value="destination">I don't have one</option>  
  </select>
</fieldset>
<fieldset>
  <label for="preferrence" id="preferrence">
    What is your preferred way to travel?
  </label>
  <input type="checkbox" name="preferrence" value="airplane"> By Airplane
  <input type="checkbox" name="preferrence" value="train"> By Train
  <input type="checkbox" name="preferrence" value="bus"> By Bus
  <input type="checkbox" name="preferrence" value="car"> By Car
  <input type="checkbox" name="preferrence" value="bicycle">By Bicycle
  <input type="checkbox" name="preferrence" value="feet"> By Feet
</fieldset>
<fieldset>
  <legend>
    Travel Experience
  </legend>
  <label>Please tell us about your travel experience</label>
  <textarea name="experience" id="comment-experience" rows="5" cols="50" ></textarea>
</fieldset>
<input type="submit" id="submit" value="submit">
</form>
  </body>
</html>

/* file: styles.css */
body {
background-color: #e5e6eb;
width: 100%;
height: 100vh;
margin: 0;
font-family: Times New Roman;
font-size: 16px
}

h1, p {
margin: 1em auto;
text-align: center;
}

form {
width: 80vw;
max-width: 500px;
min-width: 300px;
margin: 0 auto;
padding-bottom: 2em;
}

fieldset {
  border: none;
  padding: 2rem 0;
  border-bottom: 3px solid #999999

}
fieldset:last-of-type {
  border-bottom: none;
}
label {
  display: block;
  margin: 0.5rem 0;
}
input, textarea, select {
  margin: 10px 0 0 0;
  width: 100%;
  min-height: 0.5em;
}

input, textarea {
  border: 1px solid #777777;
}
.inline {
  width: unset;
  margin: 0 0.5em 0 0;
  vertical-align: middle;
}
input[type="submit"]{
  display: block;
  width: 60%;
  margin: 1em auto;
  height: 2em;
  font-size: 1.1rem;
}



Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Survey Form - Build a Survey Form

in the line of option value it says locatio and not location, you have a typo

fixed it, thank you, however, it didn’t fix the alignment for the text and buttons

All your label elements are set to display: block making them take up the full width. As such, nothing can sit next to them.

All your input elements have width: 100%. As such, nothing can sit next to them.


Target the elements that need those styles. Do not apply them to all the same element types. You can scope your styles to specific child elements using a class on their containers. Or apply the styles using classes you add to the specific elements.

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