Forum Moderators: open
There may be other ways to get the same appearance, though. For example, if you want to indent the first line of a paragraph, you can use text-indent in css.
There are also ways to create a hanging indent effect with css.
One place the Tab key is used is in moving from form field to form field on a web page. You can set the tab order for fields, too.
Hope that helps.
<pre class="myown">
Name[[tab]]Age
Ann[[tab]]23
</pre>
Replace [[tab]] with the normal tab key on your keyboard. Normaly, <pre> uses a fixed character font like Courier, but if you add a font definition to the myown class in your CSS file, it will show up like normal text, only with tabs enabled.
I try to design to the current web standards, so I wouldn't use <pre> like that. Anyway, since you'd have to use CSS, there are more direct ways to get the same effect, don't you think?
The question was if there was a tab in HTML and yes, there is. And for a quick solution for a limited set of users it can be used. Personally I use CSS or tables for all formatting because it gives you so much more freedom like:
For such a known user base it might be a also a solution to use MS Word, and save the document as HTML. MS Word adds a lot of formatting codes to the HTML to assure that the layout is fixed. In this way you can use different fonts etc. I wouldn't use MS Word as your default HTML generator though, because it output reeeaaalllllly a lot if garbage. Small text will easily expand to 100k or more.
I've dug around a bit, and found this snippet of Javascript which should work (I've not tested it) in IE6:
<script type="text/javascript">
function doTab()
{
var e = window.event;
if (e.keyCode == 9) // tab
{
e.srcElement.value = e.srcElement.value + "\t";return false;
}
return true;
}
</script> Then add to the textarea tag:
<textarea name="whatever" rows="20" cols="75" onkeydown="return doTab();"> Is that more what you're looking for?
(And the discussion about <pre> was also interesting to read).
EDIT:
Adding a focus to the function makes the cursor stay in the text area as you type, which is more useful:
function doTab() {
var e = window.event;
if (e.keyCode == 9) {
e.srcElement.value = e.srcElement.value + "\t";
e.srcElement.focus()
return false;
}
return true;
}