Scroll to content

Automatically marking HTTPS links

Encryption is becoming more and more essential on the modern Web. The next iteration of the HTTP protocol, http/2, will require SSL everywhere, and if you’re still using HTTP 1.1 it’s still highly recommended. Let’s Encrypt is a free automated certificate authority that makes it easy to request and renew basic SSL certificates automatically so really there’s no reason not to have one.

That got me thinking, wouldn’t it be nice if we could automatically label HTTPS and HTTP links? A bit of head-scratching later, this is what I came up with:

a[href^="http://"] {
  color: #9f2222;
}
 
a[href^="https://"] {
  color: #115f11;
}
 
a::before {
  font-family: "FontAwesome", sans-serif;
  padding-right: 0.2em;
}
 
a[href^="http://"]::before {
	content: "\f13e";
}
 
a[href^="https://"]::before {
	content: "\f023";
}

All of which leads to HTTPS links that look like this, and HTTP links that look like this.

This entry was posted in CSS. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)