HTML5 Template: A Basic Code Template to Start Your Next Project

  • You are here: Free PHP » Uncategorized » HTML5 Template: A Basic Code Template to Start Your Next Project

If you’re looking for a basic HTML5 template that’s both free and easy to use, you’re in the right place.

Our simple template gives you a basic structure that you can customize to fit your website needs. The download also includes a commented HTML5 file with helpful details for your web project.

What you see in the image below is boilerplate markup (a blank HTML document template) for HTML5-capable web pages.

HTML5 template screenshot in Sublime Text

Click the download button to get your HTML5 template, then keep reading to understand what comes in the folder and how to use everything.

Click to download the HTML5 template

Open the HTML5 code template in whatever program you use and then fill out the blanks.

Understanding the commented version of the HTML5 template

The highlighted comments in this version of the HTML5 code template will teach you about each item in the document.

HTML5 commented version

Explanation of the basic HTML5 template

This HTML5 template, in my opinion, is the bare minimum for a practical HTML5-capable document.

I’d like to elaborate on some of the decisions I’ve made with this template.

Placement of scripts

It’s best practice to place your render-blocking scripts near the end of your HTML document, right before the closing </body> tag (or choose not to use them in the first place).

Doing that allows the visual content, CSS and document object model to render first, improving the perceived speed and performance of your web pages.

But referencing scripts at the end isn’t always possible, so move your script references up the HTML document if you need to.

Also, as a form of progressive enhancement, you should preferentially use the HTML5 async attribute with your <script> references so that they can load asynchronously and in parallel, at least in web browsers that are able to.

Example:

<script src=https://www.webfx.com/blog/web-design/html5-template/"my-script.js" async></script>

Important note: These two script-placement practices can seriously break your web pages if you’re not well-versed in how JavaScript is loaded, rendered, and executed by the browser. And the reason I know this is, indeed, because of the many web pages I’ve broken in the past.

The “viewport” meta tag

The following is small-screen-specific:

<meta name="viewport" content="width=device-width, initial-scale=1">

Without this meta tag, the web page might look like this:

An HTML5 page loaded on mobile without the viewport meta tag

As you can see above, Mobile Safari will try to render the page to its default width of 980px using the device’s native PPI.

However, with the “viewport” meta tag used in this template, we tell the browser to scale the content to match the device’s width instead. This results in the following:

 

An HTML5 page with the viewport meta tag

The latter is easier to read.

Support of IE 9 and below with the HTML5 template

Despite commendable efforts from the Internet Explorer team to get their users to update to the most recent version of the browser, the reality is that there are still many people who use IE 9 and below.

To be able to render new HTML5 elements and media queries, this template has a conditional comment for serving html5shiv by Alexander Farkas and Respond.js by Scott Jehl. They’re going to be served through a reliable public CDN. The conditional comment will only load these scripts to users on IE 9 and lower.

In addition, this markup template has the following meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

This explicitly instructs Internet Explorer to use the most current layout engine available in the user’s machine.

As we move forward to the future and the use of outdated IE browsers is no longer an issue, I’d love to be able to remove these browser-specific items from the template. Many will argue with me that browser-specific markup doesn’t belong in a generic boilerplate, but I’m favoring practicality/pragmatism over semantics in this instance.

A bit of extra markup and conditionally serving two tiny scripts only those that require it is a reasonable compromise for being able to use HTML5 elements and media queries.

Android and iOS home screen icons for the HTML5 code template

About 36% of this HTML5 template is already for the sake of supporting a specific browser family, 聽so I’ve decided not to include the home screen icon references by default.

However, it’s a good idea to add Android and iOS home screen icons for your web pages because these are two very popular mobile operating systems. Here’s my suggested markup for that:

<meta name="mobile-web-app-capable" content="yes"> <link rel="icon" sizes="196x196" href=""> <link rel="apple-touch-icon" sizes="152x152" href="">

The above will have you covered for the Android Homescreen and iOS Home screen (from the lowest-resolution iOS device up to iPad with Retina display). For now.

Note: Don’t forget to fill out the blank href references to point to the URI of your icons.

For more information on what dimensions your icons should be, read these docs:

  • for Android
  • for iOS

As an aside, I hope in the near-future that we can all agree on a non-proprietary way of including bookmarking icons that use an open-source image format.

HTML indentation style

My preference for HTML documents is to start the indentation at the first child element within the <body> element. This is more practical and readable as a developer because after the boilerplate items are set, they will rarely change while we’re developing the front-facing markup.

However, what does change quite often while we’re developing the front-end is the stuff inside the <body> element.

For example, I tend to update element hierarchies, element types and nested structures quite frequently while I’m building out the layout and content structure.

If I were to start the indentation at the <head> element, which would be the semantic thing to do, by the time I get to the meat of the document, I’m already at the second tab stop.

<!DOCTYPE html> <head> <title></title> <!-- etc. --> </head> <body> <! -- 2nd tab stop --> <nav id="top"> <ul> <li><a>Link 1</a></li> <li><a>Link 2</a></li> <li><a>Link 3</a></li> </ul> </nav> </body> </html>

Working with deep hierarchies, a lot of nesting, and tons of content, those two extra tab stops add up to quite a lot of re-indenting. In addition, I work on a small screen sometimes, and having that type of indentation schema makes code hard to read and scroll through.

Instead, this is what I prefer doing:

<!DOCTYPE html> <head> <title></title> <!-- etc. --> </head> <body> <nav id="top"> <! -- Start indent at the first child element --> <ul> <li><a>Link 1</a></li> <li><a>Link 2</a></li> <li><a>Link 3</a></li> </ul> </nav> </body> </html>

This HTML5 template is geared for the above markup-indenting style. This style allows me to tune out the boilerplate stuff as well as to make it easier to work with the elements still being developed.

If you’re bothered by my indentation style — and I completely understand if you are, because these types of things bother me too — you can easily customize this template to implement your preferred source-formatting system. Or, better yet, use Grunt in conjunction with libraries that can automate indentation or minification for you before pushing to production.

HTML5 blank template license: public domain dedication

No need to ask permission if you want to use this HTML5 template. To be even more explicit: The template is free of any copyright restrictions. You can use, sell, modify, and distribute the template all without asking permission, providing attribution, or any other requirement. The HTML markup is under CC0 1.0 Universal. Note: I don’t own the external scripts referenced in the template so the public domain dedication only refers to the markup I wrote.

View HTML5 template information on GitHub

The post HTML5 Template: A Basic Code Template to Start Your Next Project appeared first on WebFX Blog.

  • Published on: Monday - 23 August 2021
  • Categories: Uncategorized Tags:  rss

Pages

Categories

  • Classes
  • Free PHP Related
  • Free PHP Scripts
  • Image upload
  • PHP Tutorials
  • Snippets
  • Uncategorized

Archives

  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • October 2013
  • September 2013
  • July 2013
  • June 2013
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • February 2009
  • January 2009
  • November 2008
  • September 2008
  • August 2008
  • June 2008
  • February 2008
  • January 2008
  • December 2007
  • December 2003

Tags

calendar classes cms database Eating Tips events favicon fonts form free garcinia cambogia Garcinia Cambogia Extract Apac Market Garcinia Cambogia Extract Europe Market Garcinia Cambogia Extract Market Garcinia Cambogia Extract Market By Application Garcinia Cambogia Extract Market By Rising Trends Garcinia Cambogia Extract Market Development Garcinia Cambogia Extract Market Forecast Garcinia Cambogia Extract Market Future Garcinia Cambogia Extract Market Growth Garcinia Cambogia Extract Market In Key Countries Garcinia Cambogia Extract Market Latest Report Garcinia Cambogia Extract Market Swot Analysis Garcinia Cambogia Extract Market Top Manufacturers Garcinia Cambogia Extract Sales Market Garcinia Cambogia Extract United States Market html images learn Make Market News MySQL News Penny Stock News php resize rss script Security snippets Stock News Trending Stock News Tutorial tutorials twitter
Powered by Gewgley

4617作文网淀粉肠小王子日销售额涨超10倍罗斯否认插足凯特王妃婚姻让美丽中国“从细节出发”清明节放假3天调休1天男子给前妻转账 现任妻子起诉要回网友建议重庆地铁不准乘客携带菜筐月嫂回应掌掴婴儿是在赶虫子重庆警方辟谣“男子杀人焚尸”国产伟哥去年销售近13亿新的一天从800个哈欠开始男孩疑遭霸凌 家长讨说法被踢出群高中生被打伤下体休学 邯郸通报男子持台球杆殴打2名女店员被抓19岁小伙救下5人后溺亡 多方发声单亲妈妈陷入热恋 14岁儿子报警两大学生合买彩票中奖一人不认账德国打算提及普京时仅用姓名山西省委原副书记商黎光被逮捕武汉大学樱花即将进入盛花期今日春分张家界的山上“长”满了韩国人?特朗普谈“凯特王妃P图照”王树国3次鞠躬告别西交大师生白宫:哈马斯三号人物被杀代拍被何赛飞拿着魔杖追着打315晚会后胖东来又人满为患了房客欠租失踪 房东直发愁倪萍分享减重40斤方法“重生之我在北大当嫡校长”槽头肉企业被曝光前生意红火手机成瘾是影响睡眠质量重要因素考生莫言也上北大硕士复试名单了妈妈回应孩子在校撞护栏坠楼网友洛杉矶偶遇贾玲呼北高速交通事故已致14人死亡西双版纳热带植物园回应蜉蝣大爆发男孩8年未见母亲被告知被遗忘张立群任西安交通大学校长恒大被罚41.75亿到底怎么缴沈阳一轿车冲入人行道致3死2伤奥运男篮美国塞尔维亚同组周杰伦一审败诉网易国标起草人:淀粉肠是低配版火腿肠外国人感慨凌晨的中国很安全男子被流浪猫绊倒 投喂者赔24万杨倩无缘巴黎奥运男子被猫抓伤后确诊“猫抓病”春分“立蛋”成功率更高?记者:伊万改变了国足氛围奥巴马现身唐宁街 黑色着装引猜测

4617作文网 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化