0

In the following code snippet:

<span style="width:250px">test</span><span>test2</span>

I want 'test' to occupy 250 pixels without changing the size of the text. In other words, I would like the word 'test' to print, followed by however may pixels is required to reach a total width of 250 pixels (test + blank space) then the word 'test2' to print afterwards. What CSS do I use to achieve this?

Hoa
  • 19,858
  • 28
  • 78
  • 107

4 Answers4

4

You can try like this: Demo

HTML:

<span class="width250">test</span><span>test2</span>

CSS:

.width250{        
    width:250px;
    display:block;
    float:left;
}
G.L.P
  • 7,119
  • 5
  • 25
  • 41
1

Add block display

<span style="width:250px; display:block;">test</span><span>test2</span>
iamawebgeek
  • 2,713
  • 1
  • 18
  • 34
1

You Can use CSS like this.

<span style="width: 250px; display: inline-block;">test</span>
<span>test2</span>
joe
  • 8,344
  • 9
  • 54
  • 80
0

If you don't want a new line use

display:inline-block

instead of block!

Perocat
  • 1,481
  • 7
  • 25
  • 48