1

I've tried like this:

  1. For five spaces used: &#npsp; &#npsp; &#npsp; &#npsp; &#npsp; but it is not provided proper space for all lines in my passage and I thought it is a bad coding practice.

  2. I've used 	, 	,	 , (someone wrote in Yahoo Answers). Although some are wrong in this but not anyone of this worked for me

  3. I've used <pre> &#x9;(my text)</pre> worked fine but the font of the text is changed to some ugly format of font.

  4. <tab align=6> also used but not worked for me.

I am doing coding in webview in Android to display the text on the screen.

Can anyone please help me out to provide proper horizontal tab space in front my text.

Thank you..

Vishwak
  • 89
  • 1
  • 11
  • You have not described what you wish to *achieve*. “Implementing horizontal tab” does not say that. The horizontal tab character has a well defined meaning and effect in HTML. – Jukka K. Korpela Feb 06 '15 at 14:37

3 Answers3

1

You can use the CSS style text-indent to indent the text.

Add a style like text-indent: 40px to the element that contains the text, for example using the style attribute:

<p style="text-indent:40px"></p>

You can also put the CSS in a style sheet and load the style sheet in the webview. In the style sheet you can for example specify the text-indent for all paragraph tags:

p { text-indent: 40px; }
Community
  • 1
  • 1
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • Shall I use like this ? Sorry I dont know how to implement CSS.. – Vishwak Feb 06 '15 at 12:00
  • The `style` tag is for defining style sheets, not for content. You can use the `style` attribute on the element that contains the text, I added an example above. – Guffa Feb 06 '15 at 12:08
0

Another option is using the tag <blockquote></blockquote>. But it is not its intended use, it is meant for quoting text.

danips
  • 26
  • 1
  • 3
0

Html3 had a <tab> element that did not survive into html4 or html5.

However, it is easy to define this element in CSS:

tab:before {content:"\9"; white-space:pre;}

This has the correct content - a tab character with Unicode code 9, and preserved white space. The preserved white space setting only operates on that one character, so you can write html like this:

<div>
This is a<tab/><tab/><tab/>Test<tab/><tab/>and Test<br>
Another<tab/><tab/><tab/>Test<tab/><tab/>and Test<br>
Yet Another<tab/><tab/>Test<tab/><tab/>and Test
</div>

And everything will work as you expect.

See this jsfiddle for the same example.

By default css defines the width of a tab character to be 8 times the width of a space. But you can change this in modern browsers using the CSS tab-size property.

bright
  • 4,700
  • 1
  • 34
  • 59