ข้อมูลอ้างอิงHTML

HTML โดยตัวอักษร HTML ตามหมวดหมู่ รองรับ HTML Browser แอตทริบิวต์ HTML HTML Global Attributes เหตุการณ์ HTML HTML สี HTML Canvas HTML เสียง/วิดีโอ ชุดอักขระ HTML HTML Doctypes การเข้ารหัส URL HTML รหัสภาษา HTML รหัสประเทศ HTML ข้อความ HTTP วิธี HTTP ตัวแปลง PX เป็น EM แป้นพิมพ์ลัด


แอตทริบิวต์ประเภท HTML


ความหมายและการใช้งาน

สำหรับ<button>องค์ประกอบ typeคุณลักษณะจะระบุประเภทของปุ่ม

สำหรับ<input>องค์ประกอบ typeคุณลักษณะจะระบุประเภทขององค์ประกอบ <input> ที่จะแสดง

สำหรับ<embed>, <link>, <object>, <script>, <source>, และ <style>องค์ประกอบtypeแอตทริบิวต์ระบุประเภทสื่ออินเทอร์เน็ต (เดิมเรียกว่าประเภท MIME)


นำไปใช้กับ

สามารถใช้ แอตทริบิวต์typeกับองค์ประกอบต่อไปนี้:

องค์ประกอบ คุณลักษณะ
<a> พิมพ์
<button> พิมพ์
<embed> พิมพ์
<input> พิมพ์
<link> พิมพ์
<เมนู> พิมพ์
<วัตถุ> พิมพ์
<script> พิมพ์
<translation> พิมพ์
<style> พิมพ์

ตัวอย่าง

ตัวอย่างปุ่ม

องค์ประกอบปุ่มสองปุ่มที่ทำหน้าที่เป็นปุ่มส่งหนึ่งปุ่มและปุ่มรีเซ็ตหนึ่งปุ่ม (ในรูปแบบ):

<form action="/action_page.php" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <button type="submit" value="Submit">Submit</button>
  <button type="reset" value="Reset">Reset</button>
</form>

ฝังตัวอย่าง

แอนิเมชั่นแฟลชแบบฝังที่มีประเภทสื่อที่ระบุ:

<embed src="helloworld.swf" type="application/vnd.adobe.flash-movie">

ตัวอย่างอินพุต

แบบฟอร์ม HTML ที่มีอินพุตสองประเภทที่แตกต่างกัน ข้อความและส่ง:

<form action="/action_page.php">
  Username: <input type="text" name="usrname"><br>
  <input type="submit" value="Submit">
</form>

ตัวอย่างลิงค์

ในตัวอย่างต่อไปนี้ แอตทริบิวต์ type ระบุว่าเอกสารที่ลิงก์เป็นสไตล์ชีตภายนอก:

<head>
<link rel="stylesheet" type="text/css" href="theme.css">
</head>

ตัวอย่างวัตถุ

<object> องค์ประกอบที่มีประเภทสื่อที่ระบุ:

<object width="400" height="400" data="helloworld.swf" type="application/vnd.adobe.flash-movie"></object>

ตัวอย่างสคริปต์

สคริปต์ที่มีแอตทริบิวต์ type ที่ระบุ:

<script type="text/javascript">
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>

ตัวอย่างที่มา

การใช้แอตทริบิวต์ประเภท:

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

ตัวอย่างสไตล์

ใช้แอตทริบิวต์ type เพื่อระบุประเภทสื่อของแท็ก <style> :

<style type="text/css">
h1 {color:red;}
p {color:blue;}

</style>

รองรับเบราว์เซอร์

แอตทริบิวต์typeมีการสนับสนุนเบราว์เซอร์ต่อไปนี้สำหรับแต่ละองค์ประกอบ:

Element
button Yes Yes Yes Yes Yes
embed Yes Yes Yes Yes Yes
input Yes Yes Yes Yes Yes
link Yes Yes Yes Yes Yes
object Yes Yes Yes Yes Yes
script Yes Yes Yes Yes Yes
source 4.0 9.0 3.5 4.0 10.5
style Yes Yes Yes Yes Yes