Emulate XMP tag with script tag and allow to copy content


6 days ago


15 time


Officially <xmp></xmp> is deprecated (but still supported by major browsers), so to be on the lawful side for new applications the only workaround is to replace xmp tag (that don't parse HTML's tags) is to use as I found: <script type="text/plain">...</script>.

Everything is Ok with this solution, but Firefox (ONLY) preventing to copy/paste content enclosed in <script type="text/plain"></script> tag.

Asking to fix it on bugzilla may takes 10-15 years as it is with similar firefox's issue, when one can't copy content from disabled text/textarea elements, so I asking here, may be someone get some workaround to allow copy/paste content enclosed in <script type="text/plain">...</script> or may be there is something better xmp tag replacement to be compatible with nowadays browsers and rules.

Below is example, how I'm using <script type="text/plain">...</script>

<!doctype html>
<html lang="en">
  <title>Attempt to emulate depricated XMP tag</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

    script[type="text/plain"] {
      display: block;
      width: 100%;
      white-space: pre;
      box-sizing: border-box;
      user-select:text !important;


<script type="text/plain" readonly>
  Try to select then copy and paste me somewhere else ...
    and you will fail...
      WITH FireFox ONLY !!!

 <p>raw HTML tag "p" here for example</p>



To prevent offers to use <pre> or other solutions that modified original content (converting to HTML entities) I should say, - it won't work for me, I have to have original raw content inside <script> tag.

0 answers