Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Learning coding
Front End Web Development Techdegree Student 9,937 PointsHow to place the label right besides the checkbox?
Hi everyone,
I am trying to solve this for a while now.
input type="checkbox" id="html_news" value="html-news" name="user-age">
<label for="HTML news">HTML News</label>
<input type="checkbox" id="CSS News" value="CSS News" name="user-age">
<label for="under_13" class="light">CSS News</label>
So as in the subject, how do i get the label description right beside the checkbox? :) I tried different variations with display: inline / inline-block, but haven't solved it yet. Hope you can help me. Thanks in advance.
4 Answers

Joachim Larsen
12,140 PointsTry to wrap the input tag within the label tag. When I tried this, they became inline with each other. (This also makes the label text clickable to select a checkbox or radio button), like this:
<div class="check"> <label for="HTML news"> <input type="checkbox" id="html_news" value="html-news" name="user-age"> HTML News </label> <div>

Joachim Larsen
12,140 PointsHi there! :-)
Are you maybe talking about vertical alignment? You didn't provide any of your CSS, but have you tried the vertical-align property on your input? :-)

Learning coding
Front End Web Development Techdegree Student 9,937 PointsHi Joachim :),
I mean to put checkbox and the label horizontally on one line. First the checkbox and after that the label. Here is my snapshot!

Amrit Pandey
17,595 PointsHTML:
<form>
<div class="form">
<div class="checkbox-container">
<input type="checkbox" id="html_news" value="html-news" name="user-age"> <label for="HTML news">HTML News</label>
</div>
<div class="checkbox-container">
<input type="checkbox" id="html_news" value="html-news" name="user-age"> <label for="HTML news">HTML News</label>
</div>
</div>
</form>
CSS(with flexbox):
.form{display:flex; flex-direction:column;}
.checkbox-container{display:flex;}
CSS(with normal CSS)[may conatain error]
.checkbox-container input[type="checkbox"]{display:inline-block;}
.checkbox-container label{display:inline;}
Designing forms are the main challenges.

Learning coding
Front End Web Development Techdegree Student 9,937 PointsThanks Amrit,
Only in this stage i prefer not to use flexbox. I tried that earlier in comination with bootstrap and it seemed they seemed to give conflict. I don't know maybe I didn't understand it. For now i would like to learn everything from the basics.
I have put the normal css in my code, but i think it does contain an error. https://w.trhou.se/6ul5g2kfiu

Amrit Pandey
17,595 PointsFlexbox is new, it is still basic.

Learning coding
Front End Web Development Techdegree Student 9,937 PointsLooking forward to work with flexbox as well :)
Learning coding
Front End Web Development Techdegree Student 9,937 PointsLearning coding
Front End Web Development Techdegree Student 9,937 PointsYes, that's it. Great! Thanks! :-)