开发者

Simplest HTML5 template for examples in print

开发者 https://www.devze.com 2023-03-19 18:50 出处:网络
I\'m going to be printing out a bunch of HTML5 examples that will be presented in a book format. With this constraint, space is at a premium, so every line I can remove is helpful. I\'d like a minimal

I'm going to be printing out a bunch of HTML5 examples that will be presented in a book format. With this constraint, space is at a premium, so every line I can remove is helpful. I'd like a minimal setup that is clear, but correct, and won't steer anyone down the wrong path.

This is the template I have so far:

  <!doctype html>
  <html>
    <head>
      <meta charset="utf-8">
    </head>
    <body>
      <!-- examples... -->
    </body>
  </html>

I see <meta charset="utf-8"> in every html5 template on the web. Obv开发者_Python百科iously it's best practice to keep it in, but is it so important that I can't remove it, even if it doesn't affect the examples I've provided. Likewise with <!doctype html>.

I could always provide a more robust example in the introduction, but as I expect people to cut-and-paste examples, I'd prefer to have them in a good, but concise, form. Thanks.


You've got to have the DOCTYPE, otherwise HTML5 type stuff won't work in certain browsers (notably IE9). It would probably be safe to leave out the charset - it's not like you can guarantee what charset your readers will be saving the examples in anyway. You will have to add a title element to the head - the document is not valid without it.

0

精彩评论

暂无评论...
验证码 换一张
取 消