Search code examples
htmlbackspace

Backspace in HTML


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.


Solution

  • 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.