How to hide an html text element ?

I have a ‘pre’ and a ‘p’
that I would like to make invisible
and not take up any space .
Is that possible .
This does nothing:

pre .pasteInto {
  visibility: hidden;

<pre class="pasteInto">


Turns out inline-css worked fine (chrome):

<pre contenteditable="true" class="pasteInto" style="  position: absolute;
  height: 0px;
  width: 1px;
  overflow: hidden;
  border: none;">


thanks for sharing, it is very helpful for me.

The selector would be pre.pasteInto, since you are targeting the same element with your tag and class values. Inline styles aren’t great if you are manually specifying styles, so if you can avoid them, you should go back to your initial approach :slight_smile:

Also, to have an element not take up any space, you can just set display: none instead of the extra work you are doing.


I’ll take another look at that .