tags:

views:

113

answers:

5

Hi there, I'd like to use an element like 'span' or any other regular ole' element to create a tabstop in an xhtml webpage (i.e. valid XML). The effect should be equivalent to 4 " " right next to each other (couldn't do that without putting a space between the ampersand and 'n'. Anyone know how to do this?

Edit: My initial post did not show the   What I want to do is avoid using that method if possible.

Some more details...

Supposedly, the following CSS is invalid

span {
  display:inline;
  width: 2em
}

because inline elements (from what I understand) do not have widths.

Also, this css:

span {
  display: block;
  width: 2em;
  float: (pick a direction)
}

would not work because it would cause the element to touch the edge of the block, causing irregular flow.

In the off chance that someone answers "Why on earth would you do that?" (hehe)...It's because I'm writing a legal document that requires said formatting. :-)

Thanks everyone!

Bernie

+1  A: 

If it's tabular data, use a table. That's what it's for.

Chad
+3  A: 

Try display: inline-block; in your CSS. This will generate a box element that's laid out inline.

Mark Hurd
Right ooooun. Thanks Mark!
btelles
Note that inline-block is only properly supported in FF3+, IE8+, Chrome, and Opera. IE7 and below or FF2 don't support or properly support inline-block
Chad
A List Apart had an article on styling HTML forms that used `inline-block`, and it gave Javascript for making that CSS work properly in browsers that do not support it. See http://www.alistapart.com/articles/prettyaccessibleforms/
Sarah Vessels
+1  A: 

Either use four  s,

<p>
    &nbsp;&nbsp;&nbsp;&nbsp;Text.
</p>

Or use padding-left: 20px; (or whatever pixels you want) on the element containing text

<p style="padding-left: 20px;">
    Text
</p>

Or use four regular spaces and apply white-space: pre; on the containing element.

<p style="white-space: pre;">
    Text
</p>

(of course the above are just examples and you should refactor your styles into a separate CSS file).

BalusC
A: 

Use the <div style="whitespace: pre;"> to wrap the contents -using the tab settings in the source-editor (gedit, notepad, notepad++, etc)- and any blocks that require special formatting, such as address, or quotes, in subsequent <div>s or <spans>.

David Thomas
+2  A: 

If you are writing a legal document that requires such formatting, you shouldn't leave it to CSS.

Ms2ger
Or even to any specific browser's interpretation of your CSS and HTML...
Zack Mulgrew
Come on guys, you have almost no knowledge of the use case and context. Why do you think you have enough information to draw that conclusion?
btelles
If you don't have a valid answer to the technical question, have little information about the context, and have an opinion, then please don't answer.
btelles