html5 scriptのtype属性は省略できることがある

html5 scriptのtype属性は省略できることがある

html5 scriptのtype属性は省略できることがある

html5のscript要素のtype属性はjavaxcriptの時は省略できます。
デフォルトがjavascriptにtype属性がなっているからです。

サンプルソース

 <!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8 /">
		<title>sample</title>
		<script src="/js/x.js" ></script>
	</head>
	<body>
		<p>sample</p>
	</body>
</html>

<script src=”/js/x.js” ><script>

またスプリプトを内部に書くときは<script>タグで囲みます。

サンプルソース

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8 /">
		<title>sample</title>
		<script src="/js/x.js" ><script>
		<script >
		console.log('ヤッホー');
		</script>
	</head>
	<body>
		<p>sample</p>
	</body>
</html>