Doctypeと文字コード指定

geralt / Pixabay

HTML4とHTML5でのDoctypeは大きく変更されました。

HTML4

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link rel="stylesheet" href="css/main.css" type="text/css">
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>

</body>
</html>

HTML5

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<stylelink rel="stylesheet" href="css/main.css" 省略可能:type="text/css">
<script src="js/main.js"></script>         

</head>
<body>

</body>
</html>

XHTML

<?xml version="1.0" encoding="${encoding}" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${encoding}" />
<title>Insert title here</title>
</head>
<frameset>
    <frame />
    <frame />
    <noframes>
    <body>
    <p>This page uses frames. The current browser you are using does not support frames.</p>
    </body>
    </noframes>
</frameset>
</html>