Backspace in HTML-ThrowExceptions

Exception or error:

Is there a way to achieve Backspace functionality in HTML? Do we have any special tags for this?

An example showing the need for such a thing can be found in StackOverflow itself. Please refer to Get current stack trace in Java. In the top answer, @jinguiy is trying to express Thread.currentThread().getStackTrace() but because of the site’s interpretation of links an unwanted space has been introduced.

If there is a way to include a backspace this can be avoided.

This is just one example, but in many contexts where we can’t control certain part of the output, having a backspace functionality in HTML can be quite useful.

How to solve:

HTML is stateless, so there is no possibility of backspace functionality with HTML alone. You could do something with javascript to achieve a similar effect.

Another approach, would be to buffer your output before sending it, and then process the buffered output. You could roll your own backspace tag, and then when processing the buffer, delete the backspace tag, and the character/tag before it.


You can use a negative margin:


<span>this is</span> <span class="backspace">a test</span>


.backspace { margin-left: -4px; }



As I know HTML has no tags to do it. You need to add some other language to your code to do such things.


I don’t think there’s such a functionality in HTML… but, depending on the effect you’re trying to achieve (is it a matter of visualization only?), you could act on word-spacing or letter-spacing

You can also use other techniques, like setting a negative margin on the elements.

In the specific example you linked, the space is due to this rule in the CSS:

p code {
padding: 1px 5px;}

If you remove it with firebug, the space disappears, cause there isn’t a space (try to copy and paste the text)

Instead, if the matter is that there are unwanted spaces in the text, you can try with javascript (here an example) or processing the text with a server side language


Gulta’s answer is best. Here is how to do this all within your html source:

<!-- horizontal backspace; adjust the amount of space by changing 4px -->
<style type="text/css">span.backspace{margin-left: -4px}</style>
<!-- The above sets up a "backspace command" in html in the style css-->
this is<span class="backspace"></span>a test
<!-- which can be placed any where after, and will output
this isa test


if you searching for simple and effective method to let user go back from your webpage
you can use this JavaScript code

head section

 function goBack()

and insert HTML in your body

<input type="button" value="Back" onclick="goBack()">

W3schools Source

Leave a Reply

Your email address will not be published. Required fields are marked *