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,004
  • 26
  • 72
  • 102

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,051
  • 4
  • 22
  • 40
1

Add block display

<span style="width:250px; display:block;">test</span><span>test2</span>
iamawebgeek
  • 2,436
  • 1
  • 14
  • 32
1

You Can use CSS like this.

<span style="width: 250px; display: inline-block;">test</span>
<span>test2</span>
joe
  • 7,779
  • 8
  • 49
  • 75
0

If you don't want a new line use

display:inline-block

instead of block!

Perocat
  • 1,405
  • 6
  • 24
  • 47