HTML HTML Forms Choosing Options Checkboxes

Christian Delos Reyes
Christian Delos Reyes
5,059 Points

Isn't <label> an in-line element by default?

If that's the case, why is it a necessary step to change it to an in-line on the class="light"?

1 Answer

Steven Parker
Steven Parker
155,814 Points

You're right, a <label> is in-line by default, so setting the display mode to in-line would not be needed.

But one reason you might do this in the class rule is in case the class might also be applied to other elements that have different defaults, to cause them all to be treated the same way.

Christian Delos Reyes
Christian Delos Reyes
5,059 Points

Thank you. But when I remove the display: in-line from the class rule, <label> moves to a new line as if it is a block, being under <input type="checkbox"....>

Steven Parker
Steven Parker
155,814 Points

Perhaps it's needed to override some other rule then. Can you make a snapshot of your workspace and post the link to it here?

Steven Parker
Steven Parker
155,814 Points

As I suspected, on line 88 of "main.css" there is an explicit "display: block" setting in the rule for all labels. The label.light rule overrides it to set the display mode back to inline.

Christian Delos Reyes
Christian Delos Reyes
5,059 Points

thanks steven. your answers throughout the track have been truly helpful.