Beginning XHTML

XHTML ลักษณะคล้ายๆ HTML แต่จะเข้มงวดเรื่อง syntax มากกว่า strict มากกว่า HTML
ตัวอย่างเช่น
☻ attribute ต้องเป็นตัวเล็กเท่านั้น
<TITLE> ✘
<title> ✔

☻ ค่าใน attribute ต้องใส่ ”
<img src=pic.jpg /> ✘
<img src=”pic.jpg” /> ✔

☻ ต้องมี / ปิดท้ายด้วยเสมอ
<br> ✘
<br /> ✔

☻ attributeใช้ id แทน name
<img src=”pic.jpg” name=”image” /> ✘
<img src=”pic.jpg” id=”image” /> ✔

☻ การเปิดปิด tag ต้องทำให้ถูกต้องถูกลำดับ
<b><i>xhtml</b></i> ✘
<b><i>xhtml</i></b> ✔

☻ XHTML ต้องใส่ DOCTYPE ไว้ด้านบนสุดเสมอ
(More : http://www.w3schools.com/tags/tag_doctype.asp)
แนะนำให้ใช้ XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

☻ เลิกใช้การประกาศ Language Attribute
<script language=”javascript” type=”text/javascript” ></script> ✘
<script type=”text/javascript” ></script> ✔

☻ XHTMLL ไม่สามารถใช้ Characters แบบตรงๆได้
(More : http://www.ascii.cl/htmlcodes.htm)
<title>hello >>TEST<< hello</title> ✘
<title>hello &gt;&gt;TEST &lt;&lt; hello</title> ✔

☻ ห้ามย่อค่าของ attributes
<option selected> ✘
<option selected=”selected”> ✔

☻ สำหรับการกำหนดลักษณะต่างๆ กำหรดรูปแบบ ขนาดต่างๆ ในบาง elements XHTML ห้ามใช้ attributes บางอย่าง ให้เราไปใช้ style แทน
ปล. XHTML จะเหมาะกับการใช้ร่วมกับ CSS มากกว่า
<td background=”pic.jpg”></td> ✘
<td style=”background-image:url(‘pic.jpg’);”></td> ✔

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
✎ <a> Must not contain other <a> elements.
✎ <pre> Must not contain the <img>, <object>, <big>, <small>, <sub>, or <sup> elements.
✎ <button> Must not contain the <input>, <select>, <textarea>, <label>, <button>, <form>, <fieldset>, <iframe> or <isindex> elements.
✎ <label> Must not contain other <label> elements.
✎ <form> Must not contain other <form> elements.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
ตัวอย่างการเขียน XHTML
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<title></title>
<meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″ />
</head>
<body></body>
</html>
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
The <marquee></marquee> tag creates a scrolling text marquee. This tag is not part of the XHTML specification
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
XHTML Reference
http://www.w3schools.com/tags/default.asp
http://xhtml.com/en/xhtml/reference/
http://www.december.com/html/x1tran/– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Markup Validation Service (ตรวจสอบความถูกต้องของโค้ด)
http://validator.w3.org/#validate_by_upload
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
attributes = คุณสมบัติ , ลักษณะ
elements = องค์ประกอบ