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 … Read more

Space Before Closing Slash?

The answer is people wish to adhere to Appendix C of the XHTML1.0 specification. Which you only need to do if you are serving XHTML as text/html. Which most people do, because XHTML’s real MIME type (application/html+xml) does not work in Internet Explorer. No current browser cares for the space. Browsers are very tolerant of … Read more

How do you make a div “tabbable”?

Add tabindex attributes to your div elements. Example: <div tabindex=”1″>First</div> <div tabindex=”2″>Second</div> Per steveax’s comment, if you don’t want the tab order to deviate from where the element is in the page, set the tabindex to 0: <div tabindex=”0″>First</div> <div tabindex=”0″>Second</div>

CSS table column autowidth

The following will solve your problem: td.last { width: 1px; white-space: nowrap; } Flexible, Class-Based Solution And a more flexible solution is creating a .fitwidth class and applying that to any columns you want to ensure their contents are fit on one line: td.fitwidth { width: 1px; white-space: nowrap; } And then in your HTML: … Read more

When should one use HTML entities?

Based on the comments I have received, I looked into this a little further. It seems that currently the best practice is to forgo using HTML entities and use the actual UTF-8 character instead. The reasons listed are as follows: UTF-8 encodings are easier to read and edit for those who understand what the character … Read more

IE 8: background-size fix [duplicate]

As posted by ‘Dan’ in a similar thread, there is a possible fix if you’re not using a sprite: How do I make background-size work in IE? filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src=”https://stackoverflow.com/questions/4885145/images/logo.gif”, sizingMethod=’scale’); -ms-filter: “progid:DXImageTransform.Microsoft.AlphaImageLoader( src=”https://stackoverflow.com/questions/4885145/images/logo.gif”, sizingMethod=’scale’)”; However, this scales the entire image to fit in the allocated area. So if your using a sprite, this may … Read more

How to make PDF file downloadable in HTML link?

This is a common issue but few people know there’s a simple HTML 5 solution: <a href=”https://stackoverflow.com/questions/364946/./directory/yourfile.pdf” download=”newfilename”>Download the pdf</a> Where newfilename is the suggested filename for the user to save the file. Or it will default to the filename on the serverside if you leave it empty, like this: <a href=”https://stackoverflow.com/questions/364946/./directory/yourfile.pdf” download>Download the pdf</a> … Read more