Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render tab characters in HTML [duplicate]

Tags:

html

I have to render some text to a web page. The text is coming from sources outside my control and it is formatted using newlines and tab characters.

New lines (\n) can be replaced by br tags, but what about preserving tabs? A brief search reveals there is no way to directly render tab characters in HTML.

like image 838
Midhat Avatar asked Apr 19 '10 06:04

Midhat


1 Answers

replace \t with      .

Each space you want will be a  

As pointed out this isn't completely correct as it only pretends to be a tab as HTML doesn't actually output format a tab as you would expect.

like image 174
Rippo Avatar answered Oct 14 '22 03:10

Rippo