ความหมายและการใช้งาน
สำหรับองค์ประกอบปุ่มที่ type แอตทริบิวต์ระบุชนิดของปุ่ม
สำหรับองค์ประกอบของการป้อนข้อมูล type แอตทริบิวต์ระบุชนิดของ <input> องค์ประกอบที่จะแสดง
สำหรับองค์ประกอบเมนู type แอตทริบิวต์ระบุชนิดของเมนู
สำหรับฝังเชื่อมโยงวัตถุสคริปต์แหล่งที่มาและองค์ประกอบสไตล์ประเภทแอตทริบิวต์เขาที่ระบุชนิดของสื่ออินเทอร์เน็ต (เดิมชื่อชนิดไมม์)
นำไปใช้กับ
type แอตทริบิวต์ที่สามารถใช้กับองค์ประกอบต่อไปนี้:
องค์ประกอบ | คุณลักษณะ |
---|---|
<button> | type |
<embed> | type |
<input> | type |
<link> | type |
<menu> | type |
<object> | type |
<script> | type |
<source> | type |
<style> | type |
ตัวอย่าง
Button ตัวอย่าง
สององค์ประกอบปุ่มที่ทำหน้าที่เป็นปุ่มเดียวและปุ่มรีเซ็ตหนึ่ง (ในรูปแบบ) ส่ง:
<form action="demo_form.asp" 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 ตัวอย่าง
ภาพเคลื่อนไหวแฟลชฝังอยู่กับชนิดของสื่อที่ระบุ
<embed src="helloworld.swf"
type="application/vnd.adobe.flash-movie">
ลองตัวเอง» Input ตัวอย่าง
รูปแบบ HTML ที่มีสองประเภทการป้อนข้อมูลที่แตกต่างกัน ข้อความและส่ง:
<form action="demo_form.asp">
Username: <input type="text" name="usrname"><br>
<input type="submit" value="Submit">
</form>
ลองตัวเอง» Link ตัวอย่าง
ในตัวอย่างต่อไปนี้ type จะบอกว่าเอกสารที่เชื่อมโยงเป็นแผ่นลักษณะภายนอก:
<head>
<link rel="stylesheet" type="text/css" href="theme.css">
</head>
ลองตัวเอง» Menu ตัวอย่าง
เมนูบริบท:
<menu type="context" id="mymenu">
<menuitem label="Refresh"
onclick="window.location.reload();" icon="ico_reload.png">
</menuitem>
<menu label="Share on...">
<menuitem label="Twitter"
icon="ico_twitter.png"
onclick="window.open('//twitter.com/intent/tweet?text='+window.location.href);">
</menuitem>
<menuitem label="Facebook" icon="ico_facebook.png"
onclick="window.open('//facebook.com/sharer/sharer.php?u='+window.location.href);">
</menuitem>
</menu>
<menuitem label="Email This Page"
onclick="window.location='mailto:?body='+window.location.href;"></menuitem>
</menu>
ลองตัวเอง» Object ตัวอย่าง
<object> องค์ประกอบที่มีชนิดของสื่อที่ระบุ
<object width="400" height="400" data="helloworld.swf"
type="application/vnd.adobe.flash-movie"></object>
ลองตัวเอง» Script ตัวอย่าง
สคริปต์ที่มี type แอตทริบิวต์ที่ระบุ:
<script type="text/javascript">
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
ลองตัวเอง» Source ตัวอย่าง
การใช้งานของ type แอตทริบิวต์:
<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>
ลองตัวเอง» Style ตัวอย่าง
ใช้ type แอตทริบิวต์เพื่อระบุชนิดของสื่อของ <style> Tag:
<style type="text/css">
h1 {color:red;}
p {color:blue;}
</style>
ลองตัวเอง» สนับสนุนเบราว์เซอร์
type
แอตทริบิวต์มีการสนับสนุนเบราว์เซอร์ต่อไปนี้สำหรับแต่ละองค์ประกอบ:
ธาตุ | |||||
---|---|---|---|---|---|
button | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |
embed | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |
input | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |
link | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |
menu | ได้รับการสนับสนุน | ได้รับการสนับสนุน | 8.0 (เฉพาะ type = "บริบท") | ได้รับการสนับสนุน | ได้รับการสนับสนุน |
object | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |
script | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |
source | 4.0 | 9.0 | 3.5 | 4.0 | 10.5 |
style | ใช่ | ใช่ | ใช่ | ใช่ | ใช่ |