1. 基本語法

宣告

  • MIME Type設定為text/html
  • DOCTYPE宣告方式為<!DOCTYPE html>
  • 部分標籤結尾可省略
  • 標籤要巢狀排列,不可交錯

元素及標籤

沒有太大變化詳細請參閱供共筆XHTML

範例

<!DOCTYPE html>
<html>
<head>
<title>Sample page</title>
<meta charset="UTF-8">
<style type="text/css"></style>
</head>
<body>
<h1>Sample page header</h1>
<p>This is a <a href="demo.html">simple</a> sample.</p>
<!-- this is a comment -->
  <input type="button" name="demo" value="Button1" disabled>
  </body>
</html>

XHTML的情況

  • MIME Type設定為text/xml
  • 必須多定應html namespace
  • 開頭必須指定文件編碼
  • 所有屬性並須指定在attribute裡面
  • 英文字大小寫有區分(case sensitive)
<?xml version="1.0" encoding="UTF-8"?>
<html ="http://www.w3c.org/1999/xhtml">
<head>
<title>Sample page</title>
<style type="text/css"></style>
</head>
<body>
<h1>Sample page header</h1>
<p>This is a <a href="demo.html">simple</a> sample.</p>
<!-- this is a comment -->
<input type="button" name="demo" value="Button1" disabled="disabled"/>
</body>
</html>