Aligning input type="submit"

Tell us what’s happening:
I am going bonkers trying to understand why the Submit button does not align to the “edges” that the rest of the form elements align to. It is nested within form, so the padding and other layout should apply.

Your code so far

HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>freeCodeCamp Survey Form</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
  </head>
  
  <body>
    <h1 id="title">freeCodeCamp Survey Form</h1>
    <p id="description">Thank you for taking the time to help us improve the platform</p>
    <form action='https://survey-form.freecodecamp.rocks' id="survey-form">
      <fieldset>
        <label id="name-label">Name<input type="text" id="name" placeholder="Enter your name" required ></label>
        <label id="email-label">Email<input type="email" id="email" placeholder="Enter your email" required ></label>
        <label id="number-label">Age (optional)<input type="number" id="number" min="10" max="99" placeholder="Age" ></label>
      </fieldset>
      <fieldset>
        <label>Which option best describes your current role?
          <select class="dropdown" id="dropdown">
            <option value="">Select current role</option>
            <option value="1">Student</option>
            <option value="2">Full Time Job</option>
            <option value="3">Full Time Learner</option>
            <option value="4">Prefer not to say</option>
            <option value="5">Other</option>
          </select>
        </label>
      </fieldset>
      <fieldset>
        <p>Would you recommend freeCodeCamp to a friend?</p>
        <lable><input type="radio" name="recommend" class="inline" value="1" />Definitely</label><br/>
        <lable><input type="radio" name="recommend" class="inline" value="2"/>Maybe</label><br/>
        <lable><input type="radio" name="recommend" class="inline" value="3"/>Not Sure</label>
      </fieldset>
      <fieldset>
        <label>What is your favorite feature of freeCodeCamp?
          <select class="dropdown" id="dropdown2">
            <option value="">Select an option</option>
            <option value="1">Challenges</option>
            <option value="2">Projects</option>
            <option value="3">Community</option>
            <option value="4">Open Source</option>
          </select>
        </label>
      </fieldset>
      <fieldset> 
         <p>What would you like to see improved? <span>(Check all that apply)</span></p>
         <label><input type="checkbox" class="inline" value="1"/>Front-end Projects</label>
         <label><input type="checkbox" class="inline" value="2"/>Back-end Projects</label>
         <label><input type="checkbox" class="inline" value="3"/>Data Visualization</label>
         <label><input type="checkbox" class="inline" value="4"/>Challenges</label>
         <label><input type="checkbox" class="inline" value="5"/>Open Source Community</label>
         <label><input type="checkbox" class="inline" value="6"/>Gitter help rooms</label>
         <label><input type="checkbox" class="inline" value="7"/>Videos</label>
         <label><input type="checkbox" class="inline"/ value="8">City Meetups</label>
         <label><input type="checkbox" class="inline" value="9"/>Wiki</label>
         <label><input type="checkbox" class="inline" value="10"/>Forum</label>
         <label><input type="checkbox" class="inline"  value="11"/>Additional Courses</label>
      </fieldset>
      <fieldset>
        <label>Any comments or suggestions?
          <textarea name="comments" rows="5" cols="30" placeholder="Enter your comments here..."></textarea>
			  </label>
      </fieldset>
      <fieldset>
        <input id="submit" type="submit" value="Submit">
      </fieldset>
    </form>

  </body>

</html>

CSS:

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  z-index: -1;
  background: var(--color-darkblue);
  background-image: linear-gradient(
      115deg,
      rgba(58, 58, 158, 0.8),
      rgba(136, 136, 206, 0.7)
    ),
    url(https://cdn.freecodecamp.org/testable-projects-fcc/images/survey-form-background.jpeg);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

h1, p {
  margin: 1em auto;
  text-align: center;
  font-family: Tahoma;
	font-size: 16px;
  color: #ffffff;
  font-weight: 100;
}

h1 {
  font-size: 1.7em;
  margin-bottom: -10px;
  }

p {
  font-style: italic;
  margin-bottom: 40px;
}

form p {
  font-style: normal;
  text-align: left;
  margin-bottom: 10px;
}

form {
  width: 60vw;
	max-width: 500px;
	min-width: 300px;
	margin: 0 auto;
  padding: 1em;
  background-color: #1b1b32;
  opacity: 0.85;
	color: #ffffff;
  font-family: Tahoma;
	font-size: 16px;
  border-radius: 3px;
}

fieldset {
  border: none;
}

label {
  display: block;
	margin: 0.5rem 0;
}

input,
textarea,
select {
  margin: 10px 0 0 0;
	width: 100%;
  min-height: 2em;
}

.inline {
  width: unset;
  margin: 0 0.5em 0 0;
  vertical-align: middle;
}

input[type="submit"] {
  display: block;
  width: 93%;
  margin: 0 auto 1.25rem auto;
  font-size: 1.1rem;
  background-color: #37af65;
  border-color: #37af65;
  color: #ffffff;
  border-radius: 3px;
  font-family: Tahoma;
  font-size: .9rem;
  border: none;
}

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
  border-radius: 5px;
  padding-left: 10px;
  font-family: Tahoma;
  font-size: .9rem;
}

input[type="text"],
input[type="email"],
input[type="number"],
select {
  min-height: 2.5em;
  border: none;
}

Your browser information:

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

Challenge: Build a Survey Form

Link to the challenge:

Please post all your HTML and CSS.

1 Like

Updated. Thanks. Is that best practice for all posts?

Yes, otherwise it is hard to test.

You have this on the button

width: 93%;

If you want it to be full width then remove it or set it to 100%


If I misunderstood the question just let me know.

1 Like

It seems to be a little finiky on codepen.io which i pasted it to for saving, but otherwise it looks good. Thanks for your responsiveness…pun intended.

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