Possible Duplicate:
Specifying Tab-Width?
I need to print a tab character in a pre tag. The HTML character for tab is 	
but on all browsers I tried it renders to look like 8 spaces.
Is there a way to adjust this to render to be the width of 4 spaces or is there another HTML character I can use that is 4 spaces?
The Proper Way. Tabs are for tabulating data. The proper way to tabulate data in HTML is to use the table tag. Every line in your original string translates to a row in the table, while each tab in the original string starts a new (left-aligned) cell in the table.
The tab character can be inserted by holding the Alt and pressing 0 and 9 together.
It is equivalent to the tab character as such. Thus, from the HTML viewpoint, there is no need to “escape” it using the character reference; but you may do so e.g. if your editing program does not let you enter the character conveniently.
While I agree with the first answer that you might as well just put 4 spaces, there does seem to be some support for a tab-size
property within CSS (though IE support is lacking):
pre {
-moz-tab-size: 4; /* Firefox 4+ */
-o-tab-size: 4; /* Opera 11.5 & 12.1 only */
tab-size: 4; /* Chrome 21+, Safari 6.1+, Opera 15+ */
}
Only effective using white-space: pre
or white-space: pre-wrap
(or within <pre>
tags).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With