Reputation: 6355
<div id="combobox">
<label><input type="checkbox" id="tag3"
name="checkbox" onclick="toggleTag('tag3')"/>DialogProc</label><br/>
<label><input type="checkbox" id="tag2"
name="checkbox" onclick="toggleTag('tag2')"/>fds</label><br/>
</div>
I'm using div
as a container for the checkboxes and their labels. I'm using <br/>
to position one below another. Is there any way to have the same layout without using <br/>
(css)?
Upvotes: 0
Views: 132
Reputation: 68626
Better practice would be to separate them by <p>
elements instead:
<p><label for="tag 3"><input type="checkbox" id="tag3"
name="checkbox" onclick="toggleTag('tag3')"/>DialogProc</label></p>
<p><label for="tag2"><input type="checkbox" id="tag2"
name="checkbox" onclick="toggleTag('tag2')"/>fds</label></p>
Also note that it is advisable to give the labels a for attribute to associate them with an input for multiple reasons (e.g. accessibility). You'd use <label for="tag3">
for the label for your first <input type="checkbox" id="tag3">
for example.
If you wanted to reduce the margins caused by using <p>
elements, then you'd just apply some basic CSS rules to them, e.g.
p {
margin:0px;
}
Upvotes: 4