HTML script 태그

1 개요[ | ]

HTML script tag
HTML script 태그

2 기본 사용 방법[ | ]

HTML5 방식 ★
html
Copy
<script>
document.write('Hello');
</script>
→ script 태그에 type 속성 생략 가능 (기본값 "text/javascript")[1]
→ 예제: http://zetawiki.com/ex/js/hello.php
XHTML 방식
html
Copy
<script type="text/javascript">
//<![CDATA[
document.write('Hello');
//]]>
</script>

3 외부 파일 임포트[ | ]

html
Copy
<script src="위치/파일명.js"></script>

4 같이 보기[ | ]

5 주석[ | ]

  1. HTML 4에서는 필수, HTML5에서는 선택적. 구글 HTML/CSS 스타일 가이드에서도 생략

6 참고[ | ]

  • HTML 커스텀 태그
    Error: Element asdf not allowed as child of element body in this context. (Suppressing further errors from this subtree.) HTML5 검사 도구에서 에러가 나옵니다. 커스텀 태그를 만들 때, Mywikier