Tell us what’s happening:
Hello,
I’m trying to get the radiobuttons like in the survey example. They are naturally next to each other, but they should be among each other (Sorry, not an an English native speaker, I hope you know what I mean).
Now, my idea was to turn the id I gave my radiobuttons into an block-element with display. This actually worked out but there is a problem. Since the label and the input-elements have to have the same id it will also turn the label elements into block-elements I think. So the radiobuttons are among each other now, BUT the labels don’t stay to the right, they will also go into the next row. So obviously I have a thinking mistake and I don’t know how to solve it. Is there maybe a possibility to design the input-id and the label-id independent from each other even though it’s the same id?
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>https://survey-form.freecodecamp.rocks</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1 id="title">freeCodeCamp Survey Form</h1>
<p id="description">Thank your for taking the time to help us improve the platform</p>
<form id="survey-form">
<fieldset>
<label for="name">Name<input id="name" type="text" placeholder="Enter your name" required/></label>
<label for="email">Email<input id="email" type="email" placeholder="Enter your Email" required/></label>
<label for="number">Age(optional)<input id="number" type="number" min="10" max="99" placeholder="Age"/></label>
<h2>Which option describes best your current role?</h2>
<select id="dropdown">
<option value=""></option>
<option value="1">Select current role</option>
<option value="2">Student</option>
<option value="3"> Full Time Job</option>
<option value="4"> Full Time Learner</option>
<option value="5">Prefer not to say</option>
<option value="6">Other</option>
</select>
</fieldset>
<fieldset>
<h3>Would you recommend freeCodeCamp to a friend?</h3>
<label for="Yes"><input id="Yes" type="radio" name="attribute"/>Yes</label>
<label for="Maybe"><input id="Maybe" type="radio" name="attribute"/>Maybe</label> <label for="Not Sure"><input id="Not Sure" type="radio" name="attribute"/>Not Sure</label>
</fieldset>
</form>
</body>
</html>
/* file: styles.css */
h1{text-align: center;}
h2, h3{text-align: center;
color:white;
font-size: 20px;}
p{text-align: center;}
fieldset{background-color:darkblue;}
#name, #email, #number{display:block;
margin-top: 10px;
margin-bottom: 10px;
width: 100%;
border-radius: 8px;
border-color: blue;
}
label{color: white;}
#dropdown{
width: 100%;
border-radius: 8px;
border-color: blue;}
#Yes, #Maybe, #Not Sure{display: block;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: Survey Form - Build a Survey Form
Link to the challenge: