A place to cache linked articles (think custom and personal wayback machine)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!doctype html><!-- This is a valid HTML5 document. -->
  2. <!-- Screen readers, SEO, extensions and so on. -->
  3. <html lang="fr">
  4. <!-- Has to be within the first 1024 bytes, hence before the `title` element
  5. See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
  6. <meta charset="utf-8">
  7. <!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
  8. <!-- The viewport meta is quite crowded and we are responsible for that.
  9. See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
  10. <meta name="viewport" content="width=device-width,initial-scale=1">
  11. <!-- Required to make a valid HTML5 document. -->
  12. <title>Visual design rules you can safely follow every time (archive) — David Larlet</title>
  13. <meta name="description" content="Publication mise en cache pour en conserver une trace.">
  14. <!-- That good ol' feed, subscribe :). -->
  15. <link rel="alternate" type="application/atom+xml" title="Feed" href="/david/log/">
  16. <!-- Generated from https://realfavicongenerator.net/ such a mess. -->
  17. <link rel="apple-touch-icon" sizes="180x180" href="/static/david/icons2/apple-touch-icon.png">
  18. <link rel="icon" type="image/png" sizes="32x32" href="/static/david/icons2/favicon-32x32.png">
  19. <link rel="icon" type="image/png" sizes="16x16" href="/static/david/icons2/favicon-16x16.png">
  20. <link rel="manifest" href="/static/david/icons2/site.webmanifest">
  21. <link rel="mask-icon" href="/static/david/icons2/safari-pinned-tab.svg" color="#07486c">
  22. <link rel="shortcut icon" href="/static/david/icons2/favicon.ico">
  23. <meta name="msapplication-TileColor" content="#f7f7f7">
  24. <meta name="msapplication-config" content="/static/david/icons2/browserconfig.xml">
  25. <meta name="theme-color" content="#f7f7f7" media="(prefers-color-scheme: light)">
  26. <meta name="theme-color" content="#272727" media="(prefers-color-scheme: dark)">
  27. <!-- Is that even respected? Retrospectively? What a shAItshow…
  28. https://neil-clarke.com/block-the-bots-that-feed-ai-models-by-scraping-your-website/ -->
  29. <meta name="robots" content="noai, noimageai">
  30. <!-- Documented, feel free to shoot an email. -->
  31. <link rel="stylesheet" href="/static/david/css/style_2021-01-20.css">
  32. <!-- See https://www.zachleat.com/web/comprehensive-webfonts/ for the trade-off. -->
  33. <link rel="preload" href="/static/david/css/fonts/triplicate_t4_poly_regular.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" crossorigin>
  34. <link rel="preload" href="/static/david/css/fonts/triplicate_t4_poly_bold.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" crossorigin>
  35. <link rel="preload" href="/static/david/css/fonts/triplicate_t4_poly_italic.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" crossorigin>
  36. <link rel="preload" href="/static/david/css/fonts/triplicate_t3_regular.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: dark)" crossorigin>
  37. <link rel="preload" href="/static/david/css/fonts/triplicate_t3_bold.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: dark)" crossorigin>
  38. <link rel="preload" href="/static/david/css/fonts/triplicate_t3_italic.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: dark)" crossorigin>
  39. <script>
  40. function toggleTheme(themeName) {
  41. document.documentElement.classList.toggle(
  42. 'forced-dark',
  43. themeName === 'dark'
  44. )
  45. document.documentElement.classList.toggle(
  46. 'forced-light',
  47. themeName === 'light'
  48. )
  49. }
  50. const selectedTheme = localStorage.getItem('theme')
  51. if (selectedTheme !== 'undefined') {
  52. toggleTheme(selectedTheme)
  53. }
  54. </script>
  55. <meta name="robots" content="noindex, nofollow">
  56. <meta content="origin-when-cross-origin" name="referrer">
  57. <!-- Canonical URL for SEO purposes -->
  58. <link rel="canonical" href="https://anthonyhobday.com/sideprojects/saferules/">
  59. <body class="remarkdown h1-underline h2-underline h3-underline em-underscore hr-center ul-star pre-tick" data-instant-intensity="viewport-all">
  60. <article>
  61. <header>
  62. <h1>Visual design rules you can safely follow every time</h1>
  63. </header>
  64. <nav>
  65. <p class="center">
  66. <a href="/david/" title="Aller à l’accueil"><svg class="icon icon-home">
  67. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-home"></use>
  68. </svg> Accueil</a> •
  69. <a href="https://anthonyhobday.com/sideprojects/saferules/" title="Lien vers le contenu original">Source originale</a>
  70. </p>
  71. </nav>
  72. <hr>
  73. <p>You do not have to follow these rules every time. If you have a good reason to break any of them, do. But they are safe to follow every time.</p>
  74. <h2>Use near-black and near-white instead of pure black and white</h2>
  75. <p>Pure black looks unnatural on a screen, and pure white is too bright. Use close-to-black and close-to-white instead. Any other references to “black” and “white” in these rules assume you’re following this rule.</p>
  76. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/1.png"></p>
  77. <h2>Saturate your neutrals</h2>
  78. <p>A neutral is generally a black, white, or grey. If you use colour in your interface, add a little bit of that colour to your neutrals. This will make the colour palette feel more coherent. If you use the HSB colour system less than 5% saturation should do it.</p>
  79. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/2.png"></p>
  80. <h2>Use high contrast for important elements</h2>
  81. <p>Important elements means buttons, content, or anything else that the user needs to notice. A higher contrast means that the element will grab attention, which is useful for important elements. Elements that the user does not need to notice (e.g. structural elements, drop-shadows) can use as little contrast as possible.</p>
  82. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/3.png"></p>
  83. <h2>Everything in your design should be deliberate</h2>
  84. <p>You should be deliberate about absolutely everything in your design. This means whitespace, alignment, size, spacing, colour, shadows. Everything. If someone points at a random part of your design you should have an explanation for why it looks that way. If you do not do this your design will not feel coherent.</p>
  85. <p>If you are new to design you can use this rule as a prompt to learn more about what you are not deliberate about yet.</p>
  86. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/4.png"></p>
  87. <h2>Optical alignment is often better than mathematical alignment</h2>
  88. <p>Your design software can align things mathematically. But some shapes don’t suit this type of alignment. For example, some odd shapes have a visual centre that is different from their mathematical centre. Often you will need to align things by eye so that it looks right.</p>
  89. <p>It takes some practice to be able to align things by eye, but if you do it regularly you’ll quickly pick it up.</p>
  90. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/5.png"></p>
  91. <h2>Lower letter spacing and line height with larger text. Raise them with smaller text</h2>
  92. <p>This applies to all text. The bigger the text, the less space you need between each letter and each line. The reverse is also true. If you do not do this large text can look spread out, and small text can look too close.</p>
  93. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/6.png"></p>
  94. <h2>Container borders should contrast with both the container and the background</h2>
  95. <p>Example: If you have a card with a 1px border and a dark background, and it sits on top of an even darker background, the 1px border should be lighter than both of them. It should not be set to a brightness somewhere between the card and page background colours. Otherwise the edge of the container won’t look sharp enough. The same applies to light background colours: the 1px border should be darker than both background colours.</p>
  96. <p>In the example below the left side is incorrect and the right side is correct.</p>
  97. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/7.png"></p>
  98. <h2>Everything should be aligned with something else</h2>
  99. <p>Alignment helps us realise that things are related to each other. If something is not aligned with anything else, it feels like it does not belong in the design. Ideally each element should be aligned with other elements based on some kind of logic.</p>
  100. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/8.png"></p>
  101. <h2>Colours in a palette should have distinct brightness values</h2>
  102. <p>When colours have different brightness values, this helps them look and feel distinctive not just in hue, but in brightness. This leads to better colour palettes because colours don’t compete with each other as much.</p>
  103. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/9.png"></p>
  104. <h2>If you saturate your neutrals you should use warm or cool colours, not both</h2>
  105. <p>If you use both warm and cool colours to saturate neutrals, the colour palette will not feel coherent.</p>
  106. <p>In the example below the left side uses a warm background and a cool foreground. The right side uses a warm background and foreground.</p>
  107. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/10.png"></p>
  108. <h2>Measurements should be mathematically related</h2>
  109. <p>The spacing you use between elements, and the size of elements, should be determined by some kind of scale. This will help the design to look coherent. In the example below, every element uses multiples of 8. Horizontal and vertical grids based on a scale help if you want to make sure elements like pictures are the right size.</p>
  110. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/11.png"></p>
  111. <h2>Elements should go in order of visual weight</h2>
  112. <p>If you have a series of elements in a row or column, and some are more visually heavy than others (two buttons and three links, for example), you should arrange them like a triangle. The visually heaviest element should go first, and the least heavy element last, in order. One caveat is that the visually heaviest element should be on the outside edge. If your elements are against the right edge of the design, for example, the heaviest element should be against the right edge. Elements that go in size or weight order look more satisfying.</p>
  113. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/12.png"></p>
  114. <h2>If you use a horizontal grid, use 12 columns</h2>
  115. <p>If you’re going to break your design up into vertical columns, use 12 columns. A 12 column grid can be broken up into 1 column, 2 columns, 3 columns, and 4 columns, so it gives you a lot of flexibility.</p>
  116. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/13.png"></p>
  117. <h2>Spacing should go between points of high contrast</h2>
  118. <p>When you’re measuring out space between elements in a design—for example if you want 100px of vertical space between blocks of content on a landing page—the spacing should be from one point of high contrast to the next. This is because our eyes find the edges of elements based on contrast, so we expect the spacing to run between points of contrast.</p>
  119. <p>A white background with black paragraphs of text means that the points of contrast will be the end of one paragraph and the start of the next. But if you put a black background behind one white paragraph, the spacing should run from the end of one paragraph to the start of the black background, then again from the start of the black background to the start of the paragraph.</p>
  120. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/14.png"></p>
  121. <h2>Closer elements should be lighter</h2>
  122. <p>As elements on the screen get closer to the user, they should get lighter. This applies to both light and dark mode UIs, because it matches how the real world works.</p>
  123. <p>In the example below, the left side is incorrect and the right side is correct.</p>
  124. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/15.png"></p>
  125. <h2>Make drop shadow blur values double their distance values</h2>
  126. <p>e.g. If you create a shadow which extends 4 pixels on the Y axis, use a blur value of 8 pixels. As the element gets “closer” to the viewer, it’s a good idea to also lower the opacity of the shadow. This looks good because as elements move closer to the light source, their shadows get more blurry.</p>
  127. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/16.png"></p>
  128. <h2>Put simple on complex or complex on simple</h2>
  129. <p>A complex background (e.g. a colourful gradient fill) works best if the foreground (e.g. text) is simple. And a complex foreground element is best on a simple background. You can put simple on simple, but it tends to look plain. Complex on complex should be avoided because it’s hard to pull off and will add visual clutter.</p>
  130. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/17.png"></p>
  131. <h2>Keep container colours within brightness limits</h2>
  132. <p>The brightness difference between background and container should be within 12% for dark interfaces, and 7% for light interfaces. These percentages refer to the brightness value in the HSB colour system.</p>
  133. <p>This is based on a study of about 100 well-designed websites where I checked the brightness of containers against the backgrounds.</p>
  134. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/18.png"></p>
  135. <h2>Make outer padding the same or more than inner padding</h2>
  136. <p>In containers, inner padding is the space between elements inside the container. Outer padding is the space between the elements and the edges of the container. This outer padding should be the same or more than the inner padding. Elements that are more related should be closer together. The elements inside a container are more related to each other than they are to the container itself.</p>
  137. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/19.png"></p>
  138. <h2>Keep body text at 16px or above</h2>
  139. <p>16px is the default text size in most browsers. Text below this size gets harder to read, so it’s safest to avoid it for body text. The higher you go beyond 16px, the easier the text is to read.</p>
  140. <p>If you are writing code yourself, use whatever equivalent of pixels you prefer.</p>
  141. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/20.png"></p>
  142. <h2>Use a line length around 70 characters</h2>
  143. <p>It doesn’t matter too much if your line length is 60 or 80 characters, but go too far either side of that and you might run into subtle readability issues.</p>
  144. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/21.png"></p>
  145. <h2>Make horizontal padding twice the vertical padding in buttons</h2>
  146. <p>The standard button pattern is wider than it is tall. If you want people to recognise an element as a button, it’s a good idea to follow the pattern. In the example below, the padding above and below the label is 30px, and the padding to the left and right is 60px.</p>
  147. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/22.png"></p>
  148. <h2>Use two typefaces at most</h2>
  149. <p>A second typeface is an opportunity to reinforce the concept behind a design. It also helps add some variety to a design. It’s rarely necessary to use more than two, and it might make the design feel visually confused.</p>
  150. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/23.png"></p>
  151. <h2>Nest corners properly</h2>
  152. <p>Sometimes you will have two or more rounded corners nested together. If you want them to look right, set the inside corner radius to the outside corner radius, minus the distance between the two. In the example below the outside radius is 30px, and there is a 20px gap, so the inside corner radius is 10px.</p>
  153. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/24.png"></p>
  154. <h2>Don’t put two hard divides next to each other</h2>
  155. <p>Background transitions, container edges, and dividing lines will create hard visual divides. You should not have two or more hard divides next to each other. You can see this marked in red in the example below. More than one hard divide creates visual clutter and catches the eye. In the example I have removed the background transition so that the hard divide only comes from the container edge.</p>
  156. <p><img src="https://anthonyhobday.com/sideprojects/saferules/images/25.png"></p>
  157. </article>
  158. <hr>
  159. <footer>
  160. <p>
  161. <a href="/david/" title="Aller à l’accueil"><svg class="icon icon-home">
  162. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-home"></use>
  163. </svg> Accueil</a> •
  164. <a href="/david/log/" title="Accès au flux RSS"><svg class="icon icon-rss2">
  165. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-rss2"></use>
  166. </svg> Suivre</a> •
  167. <a href="http://larlet.com" title="Go to my English profile" data-instant><svg class="icon icon-user-tie">
  168. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-user-tie"></use>
  169. </svg> Pro</a> •
  170. <a href="mailto:david%40larlet.fr" title="Envoyer un courriel"><svg class="icon icon-mail">
  171. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-mail"></use>
  172. </svg> Email</a> •
  173. <abbr class="nowrap" title="Hébergeur : Alwaysdata, 62 rue Tiquetonne 75002 Paris, +33184162340"><svg class="icon icon-hammer2">
  174. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-hammer2"></use>
  175. </svg> Légal</abbr>
  176. </p>
  177. <template id="theme-selector">
  178. <form>
  179. <fieldset>
  180. <legend><svg class="icon icon-brightness-contrast">
  181. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-brightness-contrast"></use>
  182. </svg> Thème</legend>
  183. <label>
  184. <input type="radio" value="auto" name="chosen-color-scheme" checked> Auto
  185. </label>
  186. <label>
  187. <input type="radio" value="dark" name="chosen-color-scheme"> Foncé
  188. </label>
  189. <label>
  190. <input type="radio" value="light" name="chosen-color-scheme"> Clair
  191. </label>
  192. </fieldset>
  193. </form>
  194. </template>
  195. </footer>
  196. <script src="/static/david/js/instantpage-5.1.0.min.js" type="module"></script>
  197. <script>
  198. function loadThemeForm(templateName) {
  199. const themeSelectorTemplate = document.querySelector(templateName)
  200. const form = themeSelectorTemplate.content.firstElementChild
  201. themeSelectorTemplate.replaceWith(form)
  202. form.addEventListener('change', (e) => {
  203. const chosenColorScheme = e.target.value
  204. localStorage.setItem('theme', chosenColorScheme)
  205. toggleTheme(chosenColorScheme)
  206. })
  207. const selectedTheme = localStorage.getItem('theme')
  208. if (selectedTheme && selectedTheme !== 'undefined') {
  209. form.querySelector(`[value="${selectedTheme}"]`).checked = true
  210. }
  211. }
  212. const prefersColorSchemeDark = '(prefers-color-scheme: dark)'
  213. window.addEventListener('load', () => {
  214. let hasDarkRules = false
  215. for (const styleSheet of Array.from(document.styleSheets)) {
  216. let mediaRules = []
  217. for (const cssRule of styleSheet.cssRules) {
  218. if (cssRule.type !== CSSRule.MEDIA_RULE) {
  219. continue
  220. }
  221. // WARNING: Safari does not have/supports `conditionText`.
  222. if (cssRule.conditionText) {
  223. if (cssRule.conditionText !== prefersColorSchemeDark) {
  224. continue
  225. }
  226. } else {
  227. if (cssRule.cssText.startsWith(prefersColorSchemeDark)) {
  228. continue
  229. }
  230. }
  231. mediaRules = mediaRules.concat(Array.from(cssRule.cssRules))
  232. }
  233. // WARNING: do not try to insert a Rule to a styleSheet you are
  234. // currently iterating on, otherwise the browser will be stuck
  235. // in a infinite loop…
  236. for (const mediaRule of mediaRules) {
  237. styleSheet.insertRule(mediaRule.cssText)
  238. hasDarkRules = true
  239. }
  240. }
  241. if (hasDarkRules) {
  242. loadThemeForm('#theme-selector')
  243. }
  244. })
  245. </script>
  246. </body>
  247. </html>