Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Browser from replacing multiple space by single space?

Tags:

html

css

Browser is replacing Multiple space between words to the single space in html page. for e.g if my text is 'AB-DC 3' in Browser its showing 'AB-DC 3'. Inspect window its showing 2 spaces 'AB-DC 3'.

you can also try out yourself. just inspect element and add multiple spaces in word of any line check.

is there any solution for this?? Similar question answered cause, but not explaining how to resolve this.

like image 646
Avinash patil Avatar asked Mar 28 '16 09:03

Avinash patil


People also ask

How do you remove double spacing in JavaScript?

Use JavaScript's string. replace() method with a regular expression to remove extra spaces. The dedicated RegEx to match any whitespace character is \s . Expand the whitespace selection from a single space to multiple using the \s+ RegEx.

Does HTML support multiple sequential blank spaces?

Hello. Hello. Hello. This is perfectly fine, as if you need multiple spaces of pre-formatted text you can just use the <pre> tag.

Which of the given commands can be used to replace the multiple occurrences of spaces with single space?

Answer: Use the JavaScript replace() method.


1 Answers

Whitespace is non-significant by default, and is compacted down to a single space when rendered.

CSS can change that: white-space: pre-wrap will provide the default line-wrapping functionality that you would expect, plus the significant-whitespace behaviour of preformatted text. Best of both worlds!

like image 86
Niet the Dark Absol Avatar answered Sep 25 '22 19:09

Niet the Dark Absol