- HTML Snippets: The Most Useful Ready-to-use Examples
- HTML5 Starter Template
- Load JavaScript Asynchronously
- Define Viewport for Responsive Websites
- Get Directions Form (Google Maps)
- Base64 Encode of a 1*1px “spacer” Gif
- Regexp Pattern For Email Validation
- Bootstrap Login Form
- Valid Flash Embed
- Insert HTML Video With Flash Fallback
- iPhone Call & SMS Links
- Autocompletion With HTML5 Datalists
- Country Dropdown List For Web Forms
- Downloadable Files
- Restrict Uploads To Specific Mime Types
- Crash IE6
- Frequently Asked Questions
- What is a HTML Snippet?
- How Do I Insert HTML Code to a WordPress Post or Page?
- What Kind of Hosting is the Best for HTML?
- HTML Web Page Examples with Source Code
- HTML Web Page Example 1
- HTML WebPage Example 2
- HTML Code Example 3 (Offer Page)
- HTML Code Example 4
- Conclusion
HTML Snippets: The Most Useful Ready-to-use Examples
HTML is super easy to write, but when creating webpages you often need to do the same repetitive tasks, such as creating forms.
In this user guide, I have compiled 10+ ready-to-use HTML snippets to fasten your front-end coding.
- HTML5 Starter Template
- Load JavaScript Asynchronously
- Define Viewport for Responsive Websites
- Get Directions Form (Google Maps)
- Base64 Encode of a 1*1px “spacer” Gif
- Regexp Pattern For Email Validation
- Bootstrap Login Form
- Valid Flash Embed
- Insert HTML Video With Flash Fallback
- iPhone Call & SMS Links
- Autocompletion With HTML5 Datalists
- Country Dropdown List For Web Forms
- Downloadable Files
- Restrict Uploads To Specific Mime Types
- Crash IE6
- Frequently Asked Questions
- What is a HTML Snippet?
- How Do I Insert HTML Code to a WordPress Post or Page?
- What Kind of Hosting is the Best for HTML?
HTML5 Starter Template
When starting a new project, you need a starter template. Here is a concise and clean template to serve as a basis for your HTML5 projects.
Load JavaScript Asynchronously
One of the best features of HTML5 is the possibility to asynchronously load JavaScript files. This is done very easily, simply by adding the async attribute to your script tags:
This simple code snippet shows an asynchronous loading of a JavaScript file. This will make the page load much faster as the browser will simultaneously load both the HTML and the JavaScript file.
Define Viewport for Responsive Websites
When creating a responsive website, setting the viewport is a must.
The following HTML snippet should be inserted into the head section of your document.
This HTML snippet set the view on all screens at a 1×1 aspect ratio and remove the default functionality from iPhones and other mobile devices which render websites at full-view and allow users to zoom into the layout by pinching.
Get Directions Form (Google Maps)
Here is a simple yet powerful code snippet to create a form where the user can enter his location to get directions to a specific place. Very useful for contact pages.
Base64 Encode of a 1*1px “spacer” Gif
I don’t recommend using transparent “spacer” gifs, but I know that even in 2019, people are still using them from time to time. If you’re one of them, you’ll probably enjoy this Base64 encode of a 1*1px “spacer” gif. Way better than using an image.
Regexp Pattern For Email Validation
HTML5 allows, among other things, to validate emails using a regular expression pattern. Here is a ready to use input field with the regexp pattern to validate an email address.
Bootstrap Login Form
A very basic Bootstrap form template that can be easily enhanced and modified to suit almost any need. Use this HTML snippet as a starting point for almost any kind of simple forms, such as login forms, contact forms, etc.