monospace.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <style>
  5. pre,
  6. textarea {
  7. border: 1px dashed #AAA;
  8. background-color: #E0E0E0;
  9. color: #000000;
  10. padding: 0.5em;
  11. height: 1em;
  12. width: 90%;
  13. }
  14. blockquote {
  15. font-style: italic;
  16. }
  17. table {
  18. width: 100%;
  19. table-layout: fixed;
  20. }
  21. td {
  22. padding: 0.5em;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <p>
  28. This page let you test the rendering font-family declaration for monospaced fonts. TODO: add some references here :-)
  29. </p>
  30. <p>
  31. Erwin Dokter had the following explanation on <a href="https://bugzilla.wikimedia.org/33496">Bugzilla #33496</a>:
  32. </p>
  33. <blockquote>
  34. By default, a (Windows) browser has it's default font-sizes set at 16px for
  35. serif and sans-serif, and 13px for monospace. Except in IE, where you cannot
  36. set any font-sizes... it uses 16px for all fonts.
  37. <br/>
  38. Vector has a base font-size of 0.8em, and most browsers *correctly* scale down
  39. all fonts, including the monospace font, accordingly. So monospace is shown at
  40. 0.8 x 13px = 10px (which is perceived as 'too small'). But when you assign any
  41. font besides just "monospace", those browsers will no longer treat it as
  42. monospace and use 0.8 x 16px = 13px instead.
  43. </blockquote>
  44. <p>
  45. Additionally, it seems that textareas have their own font-size set in Chrome
  46. (but not Firefox and other browsers), making them unaffected by this behavior.
  47. </p>
  48. <p>
  49. Below are various rendering:
  50. </p>
  51. <table>
  52. <tr>
  53. <th>&lt;pre&gt;</th>
  54. <th>&lt;textarea&gt;</th>
  55. </tr>
  56. <tr>
  57. <td>
  58. <pre style='
  59. font-family: monospace;'>
  60. font-family: monospace;
  61. </pre>
  62. </td>
  63. <td>
  64. <textarea style='
  65. font-family: monospace;'>
  66. font-family: monospace;
  67. </textarea>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td>
  72. <pre style='
  73. font-family: "Courier New";'>
  74. font-family: "Courier New";
  75. </pre>
  76. </td>
  77. <td>
  78. <textarea style='
  79. font-family: "Courier New";'>
  80. font-family: "Courier New";
  81. </textarea>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td>
  86. <pre style='
  87. font-family: Courier;'>
  88. font-family: Courier;
  89. </pre>
  90. </td>
  91. <td>
  92. <textarea style='
  93. font-family: Courier;'>
  94. font-family: Courier;
  95. </textarea>
  96. </td>
  97. </tr>
  98. <tr>
  99. <td>
  100. <pre style='
  101. font-family: monospace, monospace;'>
  102. font-family: monospace, monospace;
  103. </pre>
  104. </td>
  105. <td>
  106. <textarea style='
  107. font-family: monospace, monospace;'>
  108. font-family: monospace, monospace;
  109. </textarea>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>
  114. <pre style='
  115. font-family: monospace, "Courier New";'>
  116. font-family: monospace, "Courier New";
  117. </pre>
  118. </td>
  119. <td>
  120. <textarea style='
  121. font-family: monospace, "Courier New";'>
  122. font-family: monospace, "Courier New";
  123. </textarea>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td>
  128. <pre style='
  129. font-family: monospace, Courier;'>
  130. font-family: monospace, Courier;
  131. </pre>
  132. </td>
  133. <td>
  134. <textarea style='
  135. font-family: monospace, Courier;'>
  136. font-family: monospace, Courier;
  137. </textarea>
  138. </td>
  139. </tr>
  140. <tr>
  141. <td>
  142. <pre style='
  143. font-family: monospace, Verdana;'>
  144. font-family: monospace, Verdana;
  145. </pre>
  146. </td>
  147. <td>
  148. <textarea style='
  149. font-family: monospace, Verdana;'>
  150. font-family: monospace, Verdana;
  151. </textarea>
  152. </td>
  153. </tr>
  154. <tr>
  155. <td>
  156. <pre style='
  157. font-family: monospace, DOESNOTEXISTREALLY;'>
  158. font-family: monospace, DOESNOTEXISTREALLY;
  159. </pre>
  160. </td>
  161. <td>
  162. <textarea style='
  163. font-family: monospace, DOESNOTEXISTREALLY;'>
  164. font-family: monospace, DOESNOTEXISTREALLY;
  165. </textarea>
  166. </td>
  167. </tr>
  168. </table>