I know that the clear: both property is used to clear floated elements. What about clear: left and clear: right? How and when do I use them?
I know that the clear: both property is used to clear floated elements. What
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Those values tell a box to clear only left floats or only right floats respectively. Instead of stacking horizontally to either a left float’s right, or a right float’s left, it will stack beneath the float respectively.
If you have a series of left and right floated elements,
clear: leftclears a box only from previous boxes that were floated left, andclear: rightclears it only from previous boxes that were floated right.If the boxes before a
clear: leftbox are floated right, the box itself will float right as well, as it has not cleared the right floats. Likewise when aclear: rightfollows boxes that are only floated to the left, the box itself will float left as well.Some visual explanations: