Search notes:

HTML element: pre

Compare CSS properties of <pre> with those of <div>

The HTML/Javascript snippet below compares the CSS properties of a <pre> element with those of a <div> element.
The most important differences, imho, are:
pre div
white-space pre normal
font-family monospace Times New Roman
<!DOCTYPE html>
<html>
<head>
  <title>Compare &lt;pre&gt; to &lt;div&gt;</title>
</head>
<body>

<div>abc</div>
<pre></pre>

</body>
</html>

<script>

let pre    = document.getElementsByTagName('pre')[0];
let div    = document.getElementsByTagName('div')[0];
let cssPre = window.getComputedStyle(pre);
let divPre = window.getComputedStyle(div);

console.log('x');
for(s of cssPre) {
   if (cssPre[s] != divPre[s]) {
      console.log(`${s}: ${cssPre[s]} != ${divPre[s]}`);
   }
}

</script>
Github repository about-HTML, path: /tags/pre/compare-div.html

See also

<code>
HTML elements

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758206546, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/web/HTML/tags/pre(84): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78