Search code examples
csslinehtml

How to wrap two spans into one line with CSS


I want to wrap two spans in one line with CSS.

Here is my code:

<div style="width:60px;">
    <span id="span1" style="float:left; display:inline;"></span>
    <span id="span2" style="float:left; display:inline; "></span>
</div>

But it doesn't work.

How to do that?

Edit:

I want to use the "id", either use div or span, I just want them to be in one line.

When I just use span without style, the content are not in the same line. The second line will go down.


Solution

  • Here is the working example:

    <div style="float:left;">
        <span style="display:inline; color: red;">First Span</span>
        <span style="display:inline; color: blue;">Second Span</span>
    </div>