From 3a639537b3c391866fa4597f42b72492d1ca1839 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Mon, 28 Mar 2022 18:11:55 -0700 Subject: [PATCH] Info about csp, halation - Mention pitfalls of a -based CSP - Describe halation a bit more, with an image. --- assets/p/halation.avif | Bin 0 -> 1408 bytes assets/p/halation.png | Bin 0 -> 2811 bytes assets/p/halation.webp | Bin 0 -> 2166 bytes content/posts/website-best-practices.gmi | 15 +++++++-- content/posts/website-best-practices.md | 38 +++++++++++++++++++++-- 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 assets/p/halation.avif create mode 100644 assets/p/halation.png create mode 100644 assets/p/halation.webp diff --git a/assets/p/halation.avif b/assets/p/halation.avif new file mode 100644 index 0000000000000000000000000000000000000000..bdf6957a8da814f59c00d29a1e0783359fb7f4c5 GIT binary patch literal 1408 zcmXv|3pmqz82(Q*msHGL!j4%vWlF9)WC_P5R8okH zQ#v_9Ei-b+NhFtaW3-So=RfD^`#rz+`@Z*mpYQts08k5yj-%pfU>E>}C`W){=m-!m z>iH3&(RdLLg&rw{9QA(*0923|{i_ybGD!F}VmlR#j@Z;-5TZabg(&Lm000I(5dts; z01zibwH^pYZtmSwc0o<3n8*xy@HA7jErm?kTuB0{QB;U`2B|~}loh~p)KHNTvJxQh zf4+ip>0zDH4%XzQpiz}L~<-NR~Fcs3{grTH3Bcvpn%R2hl!<$LpMc7 zgy5s)0cj~^%{yjo!J6em`^F@Z6RsarPdeq`f|tt?ZsIKQ@dZG#+kwmbK?$5 zyY%gyE#5o6uM+Mx2eU6X)~T1d--l_2>z+|s`=Gz|S~j;vpNg7uKkmH8$IzB>ZL+@U zpBy-M$|Jpa0Pzu{l8YPn!&Gs+;_~Tr!0!h9;+QLC9NLW%tr6yl@cu?dO9$`m{uDib zf7kbjb?xoPeXO_@{O@B2nrAw{h300PJC(pKvkC&@B3X}{i)s7O<$Sx9KH{6G<<|~e znTBThoL1|^eBD*1zoUcdwCCZQHmwM`;?utsF6t=uDu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HC3N7Y-`Q+rZaNd z`H~!ok28*isf=M%f8%MvQrazJJ5QP2S~J!5NLZ){nr*S&>|rIb$Z3rDW?$X*5Z@#m z%X4bq^ti=}cZ%6Vti*x%_IpJ!Fq83g0bG_o<$AZ}XqDo;OvKZ6_?mWWtaNuipMa`Y zLsu`_-P+Co^Y_x&i|M~-in*-x-Npsjj>O}sfc@r6R&2+QV{KD6#Pj!`0A3pO`@~DL zF2K|^pttR&;Cz_X{<*wtb8WEBX{!435}50O_-L$rNhE-2WKal+VgZakext~E07j06 zkUW%&IS@uW&=16e@&8l48Xxo3_^a_( N002ovPDHLkV1n|cvz-6{ literal 0 HcmV?d00001 diff --git a/assets/p/halation.webp b/assets/p/halation.webp new file mode 100644 index 0000000000000000000000000000000000000000..6bbf4d82f02282d084c8e714ce3e1a9c4a0e5469 GIT binary patch literal 2166 zcmV-+2#NPnNk&F)2mk50xORpZD>+4 zMemHe;DDiU_UFG9FsX?<=j^d9E2~2gjbRn4ge81zXFo!1=M3z(+mr333NeIf_MeKKoGL0-P?ObwQD`zI(T|k4|ED4 z*f#9lkPm+sUQ%N*4*qa@>>}%V`a_PJAtLNp?LxCUxgjs_(~RLLzQ&q0!BeVXd4P{5vlY zQXZ*3HB!a&G`>pscTjkj`LsfUtzXFOBKT~O<2qfFj=XaV5N+Wz=tRguu@^>i>&nbt zqWD1QR+#bW#Z0!?^*s{Sk)xp<5;jHM$zVnbB$6Z39g!4s7lIq(>#45E01KLjS-p3A zlP9lEPkCvaWh{9kyfp)LbY;*-m!G}9t?9GM*OsLnu-aZv!e|#`K)cZ0KKg<7X0q-F zqZ#a2D20lnURN{B!l^GozLN5xG{?oy8{_jc^4<~58`NJ_`0l`jPT-q&g7g<~m0Jovkye54zw|hOIK3rCg*OE3s=^FTwlYm87TY5XcJny!$Teh1*v$q9e&y z9@Ug$;VM_BdVMouYhC~HIeNVKTHh>fO}@iNeGi>dnEFr(c`oTwkY%ji;UO5)WSP*& z!E}mHIYBN&%%0Qr)Y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Ly?}RZy81;c(SKPLAlx*^Bkl<)-VF sIooCxWv^PG tag. In addition to not supporting certain directives, a CSP in a tag might let some items slip through: + +> At the time of inserting the meta element to the document, it is possible that some resources have already been fetched. For example, images might be stored in the list of available images prior to dynamically inserting a meta element with an http-equiv attribute in the Content security policy state. Resources that have already been fetched are not guaranteed to be blocked by a Content Security Policy that's enforced late. + +=> https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-security-policy HTML Living Standard, Content Security Policy state + ### If you must enable scripts Please use progressive enhancement³ throughout your site; every feature possible should be optional, and scripting is no exception. @@ -248,11 +254,16 @@ Note that the APCA isn't fully mature as of early 2022. Until version 3.0 of the CSS filters such as "invert" are expensive to run, so use them sparingly. Simply inverting your page's colors to provide a dark theme could slow it down or cause a user's fans to spin. -Darker backgrounds draw less power on devices with OLED screens; however, backgrounds should never be solid black. White text on a black background causes halation, especially among astigmatic readers. There has been some experimental and plenty of anecdotal evidence to support this. +Darker backgrounds draw less power on devices with OLED screens; however, backgrounds should never be solid black. White text on a black background causes halation, especially among astigmatic readers. Halation comes from the word "halo", and refers to a type of "glow" or ghosting around words. There has been some experimental and plenty of anecdotal evidence to support this: => https://www.laurenscharff.com/research/AHNCUR.html Hill, Alyson (supervised by Scharff, L.V.) Readability Of Websites With Various Foreground / Background Color Combinations, Font Types And Word Styles, 1997 => https://jessicaotis.com/academia/never-use-white-text-on-a-black-background-astygmatism-and-conference-slides/ Never Use White Text on a Black Background: Astygmatism and Conference Slides +Here's an approximation of what this kind of halation looks like: + +=> gemini://seirdy.one/misc/halation.png Fuzzy white text on black background reading "But it is not" (image/png) +=> https://www.essentialaccessibility.com/blog/accessibility-for-people-with-astigmatism image source + I personally like a foreground and background of "#ececec" and "#0c0c0c", respectively. These shades seem to be as far apart as possible without causing accessibility issues: "#0c0c0c" is barely bright enough to create a soft "glow" capable of minimizing halos, but won't ruin contrast on cheap displays. "Just disable dark mode" is a poor response to users complaining about halation: it ignores the utility of dark themes described at the beginning of this section. @@ -757,7 +768,7 @@ Before you throw up your hands and decide you can't help everyone, take another ## Further reading -Parts of this page can be thought of as an extension to the principles of Brutalist Web Design: +Parts of this page can be thought of as an extension to the principles of Brutalist Web Design, which favors "raw content true to its construction": * Content is readable on all reasonable screens and devices. * Only hyperlinks and buttons respond to clicks. diff --git a/content/posts/website-best-practices.md b/content/posts/website-best-practices.md index 0893c40..cface3f 100644 --- a/content/posts/website-best-practices.md +++ b/content/posts/website-best-practices.md @@ -69,6 +69,26 @@ sandbox allow-same-origin `default-src: 'none'` implies `script-src: 'none'`, causing a compliant browser to forbid the loading of scripts. Furthermore, the `sandbox` CSP directive forbids a [wide variety](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox) of potentially insecure actions. While `script-src` restricts script loading, `sandbox` can also restrict script execution with stronger defenses against script injection (e.g. by a browser addon).[^1] I added the `allow-same-origin` parameter so that these addons will still be able to function.[^2] +If you're able to control your HTTP headers, then use headers instead of a `` tag. In addition to not supporting certain directives, a CSP in a `` tag might let some items slip through: + +
+
+

+At the time of inserting the meta element to the document, it is +possible that some resources have already been fetched. For example, images might be stored in +the list of available images prior to dynamically inserting a meta +element with an http-equiv attribute in the Content security policy state. +Resources that have already been fetched are not guaranteed to be blocked by a Content +Security Policy that's enforced late. +

+
+
+ +-- HTML Living Standard, [Content Security Policy state](https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-security-policy) + +
+
+ ### If you must enable scripts Please use progressive enhancement (PE)[^3] throughout your site; every feature possible should be optional, and scripting is no exception. @@ -207,7 +227,18 @@ Note that the APCA isn't fully mature as of early 2022. Until version 3.0 of the CSS filters such as `invert` are expensive to run, so use them sparingly. Simply inverting your page's colors to provide a dark theme could slow it down or cause a user's fans to spin. -Darker backgrounds draw less power on devices with OLED screens; however, backgrounds should never be solid black. White text on a black background causes halation, especially among astigmatic readers. There has been some [experimental](https://www.laurenscharff.com/research/AHNCUR.html) and plenty of [anecdotal](https://jessicaotis.com/academia/never-use-white-text-on-a-black-background-astygmatism-and-conference-slides/) evidence to support this. I personally like a foreground and background of `#ececec` and `#0c0c0c`, respectively. These shades seem to be as far apart as possible without causing accessibility issues: `#0c0c0c` is barely bright enough to create a soft "glow" capable of minimizing halos, but won't ruin contrast on cheap displays. +Darker backgrounds draw less power on devices with OLED screens; however, backgrounds should never be solid black. White text on a black background causes halation, especially among astigmatic readers. Halation comes from the word "halo", and refers to a type of "glow" or ghosting around words. There has been some [experimental](https://www.laurenscharff.com/research/AHNCUR.html) and plenty of [anecdotal](https://jessicaotis.com/academia/never-use-white-text-on-a-black-background-astygmatism-and-conference-slides/) evidence to support this. + +
+
+ +The following image is an approximation of what halation looks like, cropped from Essential Accessibility. + +
+{{< picture name="halation" alt="Fuzzy white text on black background reading \"But it is not\"." >}} +
+ +I personally like a foreground and background of `#ececec` and `#0c0c0c`, respectively. These shades seem to be as far apart as possible without causing accessibility issues: `#0c0c0c` is barely bright enough to create a soft "glow" capable of minimizing halos, but won't ruin contrast on cheap displays. "Just disable dark mode" is a poor response to users complaining about halation: it ignores the utility of dark themes described at the beginning of this section. @@ -661,7 +692,8 @@ Parts of this page can be thought of as an extension to the principles of Brutal
-
    +

    Raw content true to its construction:

    +
    1. Content is readable on all reasonable screens and devices.
    2. Only hyperlinks and buttons respond to clicks.
    3. Hyperlinks are underlined and buttons look like buttons.
    4. @@ -669,7 +701,7 @@ Parts of this page can be thought of as an extension to the principles of Brutal
    5. View content by scrolling.
    6. Decoration when needed and no unrelated content.
    7. Perform­ance is a feature.
    8. -
+
— {{}},