[ale] Tabs in TEXTAREAS

John Marasco jemarasco at bellsouth.net
Thu Jun 19 16:56:03 EDT 2003


from w3c

The horizontal tab character (decimal 9 in [ISO10646] and [ISO88591] ) is usually interpreted by visual user agents as the smallest non-zero number of spaces necessary to line characters up along tab stops that are every 8 characters. We strongly discourage using horizontal tabs in preformatted text since it is common practice, when editing, to set the tab-spacing to other values, leading to misaligned documents.

In theory a tab inside a PRE element should display as 8 spaces.  As Geofrey said though, the browser should parse the #PCDATA in the TEXTAREA before rendering it and remove the whitespace.  In practice the data in a TEXTAREA is sometimes passed directly to an underlying OS object for display in the underlying OS GUI "textbox" object (whitespace and all).  This is predictable laziness because the TEXTAREA element only contains #PCDATA and the only reason to parse the data in a TEXTAREA is for standards compliance.  IE is lazy and doesn't look at the data in the TEXTAREA.  Thus, spaces, tabs and even elements are sent directly to the OS textbox object and you can replace all tabs with spaces in an IE TEXTAREA and they will display.  You would need to check your target browser to determine how compliant it is.  What Geoffrey said to do should work and is compliant but if you need to use   then you also need to preserve linefeeds in the TEXTAREA.  Unfortunately, elements in #PCDATA are supposed to cause a parsing error in a 100% compliant browser and I don't believe there is another way to preserve linefeeds.  IE shows BR elements in a TEXTAREA but replaces the   entities, Ooops.

If you want to use styles, there is an overflow style that you can use along with the height style to build a non-editable scrolling window for display only (with a SPAN, P, TD or other element).  With this method you could use a PRE element to preserve whitespace and remain confident that the expected behaviour is compliant.  Since this is sort of "non-standard" the number of browsers that have this level of compliance is another question.  I've gotten it to work with IE before but I don't have the HTML handy.

> 
> From: Christopher Fowler <cfowler at outpostsentinel.com>
> Date: 2003/06/19 Thu PM 02:04:26 EDT
> To: ale at ale.org
> Subject: [ale] Tabs in TEXTAREAS
> 
> 
> 
> I'm displaying command output in a textarea.  Is there
> any way to get the TEXTAREA to display tabs as 8 spaces?
> On way I can do it is to walk through the buffer and replace tabs
> with 8 spaces but I was thinking there maybe a way within HTML
> to do this?
> 
> Thanks,
> Chris
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
> 

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list