Is there a way to prevent a line break after a div with css?
For example I have
<div class="label">My Label:</div>
<div class="text">My text</div>
and want it to display like:
My Label: My text
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.
display:inline;OR
float:left;OR
display:inline-block;— Might not work on all browsers.What is the purpose of using a
divhere? I’d suggest aspan, as it is an inline-level element, whereas adivis a block-level element.Do note that each option above will work differently.
display:inline;will turn thedivinto the equivalent of aspan. It will be unaffected bymargin-top,margin-bottom,padding-top,padding-bottom,height, etc.float:left;keeps thedivas a block-level element. It will still take up space as if it were a block, however the width will be fitted to the content (assumingwidth:auto;). It can require aclear:left;for certain effects.display:inline-block;is the “best of both worlds” option. Thedivis treated as a block element. It responds to all of themargin,padding, andheightrules as expected for a block element. However, it is treated as an inline element for the purpose of placement within other elements.Read this for more information.