<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nicholas Whittaker</title>
    <description>The latest articles on DEV Community by Nicholas Whittaker (@nchlswhttkr).</description>
    <link>https://dev.to/nchlswhttkr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F270567%2Fd9ae6229-28c4-4922-8fee-6e39c6efba3a.jpeg</url>
      <title>DEV Community: Nicholas Whittaker</title>
      <link>https://dev.to/nchlswhttkr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nchlswhttkr"/>
    <language>en</language>
    <item>
      <title>Hiding Secret Links With CSS</title>
      <dc:creator>Nicholas Whittaker</dc:creator>
      <pubDate>Fri, 26 Jun 2020 21:56:05 +0000</pubDate>
      <link>https://dev.to/nchlswhttkr/hiding-secret-links-with-css-3jpm</link>
      <guid>https://dev.to/nchlswhttkr/hiding-secret-links-with-css-3jpm</guid>
      <description>&lt;p&gt;Every now and then I like to browse the hiring pages of companies I like and admire.&lt;/p&gt;

&lt;p&gt;Last week, I noticed an opening that didn't feature the usual prominent call-to-action prompt to apply.&lt;/p&gt;

&lt;p&gt;Instead of a button or a link, there was only a message with instructions for applicants.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"To apply, submit [...] at the URL that appears when you append the class [&lt;code&gt;secret-class&lt;/code&gt;] to this tag."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Alright then. A few clicks in devtools give the paragraph its &lt;code&gt;secret-class&lt;/code&gt;. Lo and behold, a URL appears!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"To apply, submit [...] at the URL that appears when you append the class [&lt;code&gt;secret-class&lt;/code&gt;] to this tag. &lt;strong&gt;bit.ly/...&lt;/strong&gt;"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So what's the secret sauce that makes this link show up?&lt;/p&gt;

&lt;p&gt;A further glance at devtools points to a few inlined styles in the page. Here's the key excerpt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.secret-class&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;" bit.ly/..."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#6ba53a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's break it down.&lt;/p&gt;

&lt;p&gt;Once the target paragraph has the necessary class, the CSS selector kicks in. It creates a special &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/::after"&gt;&lt;code&gt;::after&lt;/code&gt; pseudo-element&lt;/a&gt; that's placed after all of the paragraph's content.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/content"&gt;&lt;code&gt;content&lt;/code&gt; property&lt;/a&gt; used inside the block is a special property that only applies to &lt;code&gt;::before&lt;/code&gt; and &lt;code&gt;::after&lt;/code&gt; pseudo-elements. It replaces them with a provided value. In the case of this job posting, that's the application link! With a few more properties to make the link pretty, we've got a cleverly hidden link!&lt;/p&gt;

&lt;p&gt;Why employ a move like this? I could hazard a few guesses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  A hurdle for applicants to prove some level of familiarity with web tools and development (a requirement of the job)&lt;/li&gt;
&lt;li&gt;  Obscuring the application link encourages applicants to read the complete posting, rather than skimming the page and hitting apply&lt;/li&gt;
&lt;li&gt;  Dissuade third parties (web crawlers, recruiters) from finding and sharing the application link&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of the day though, I'm just hypothesising.&lt;/p&gt;

&lt;p&gt;My concern with this approach is its accessibility. It's hard to be certain that CSS &lt;code&gt;content&lt;/code&gt; will be visible to those using assistive technologies, especially screen readers.&lt;/p&gt;

&lt;p&gt;This could even be seen as discriminatory, preventing a particular audience from applying for the job. In the case of sufficiently inaccessible content, &lt;a href="https://www.w3.org/TR/WCAG20-TECHS/ARIA14.html"&gt;adding an &lt;code&gt;aria-label&lt;/code&gt;&lt;/a&gt; can make a world of difference. Even with this label, the link itself remains visually hidden!&lt;/p&gt;

&lt;p&gt;As an extra step, you can share the link between the &lt;code&gt;aria-label&lt;/code&gt; and its paragraph using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/attr"&gt;&lt;code&gt;attr()&lt;/code&gt; CSS function&lt;/a&gt;!&lt;/p&gt;




&lt;p&gt;You can see it in action in this CodePen!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/nchlswhttkr/embed/pogwJEK?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
    </item>
  </channel>
</rss>
