Hidden features of HTML

Using a protocol-independent absolute path:

<img src="//domain.example/img/logo.png"/>

If the browser is viewing an page in SSL through HTTPS, then it’ll request that asset with the HTTPS protocol, otherwise it’ll request it with HTTP.

This prevents that awful “This Page Contains Both Secure and Non-Secure Items” error message in IE, keeping all your asset requests within the same protocol.

Caveat: When used on a <link> or @import for a stylesheet, IE7 and IE8 download the file twice. All other uses, however, are just fine.

Leave a Comment