ข้อมูลอ้างอิง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


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

แอตทริบิวต์nameระบุชื่อสำหรับองค์ประกอบ HTML

คุณลักษณะ นี้nameสามารถใช้เพื่ออ้างอิงองค์ประกอบใน JavaScript

สำหรับ<form>องค์ประกอบ nameแอตทริบิวต์จะใช้เป็นข้อมูลอ้างอิงเมื่อส่งข้อมูล

สำหรับ<iframe>องค์ประกอบ nameสามารถใช้แอตทริบิวต์เพื่อกำหนดเป้าหมายการส่งแบบฟอร์ม

สำหรับ<map>องค์ประกอบ nameคุณลักษณะจะเชื่อมโยงกับ แอตทริบิวต์ <img>' usemapและสร้างความสัมพันธ์ระหว่างรูปภาพกับแผนที่

สำหรับ<meta>องค์ประกอบ nameคุณลักษณะจะระบุชื่อสำหรับข้อมูล/ค่าของ contentแอตทริบิวต์

สำหรับ<param>องค์ประกอบ nameแอตทริบิวต์จะใช้ร่วมกับvalueแอตทริบิวต์เพื่อระบุพารามิเตอร์สำหรับปลั๊กอินที่ระบุด้วย<object> แท็ก


นำไปใช้กับ

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

องค์ประกอบ คุณลักษณะ
<button> ชื่อ
<fieldset> ชื่อ
<แบบฟอร์ม> ชื่อ
<iframe> ชื่อ
<input> ชื่อ
<map> ชื่อ
<เมต้า> ชื่อ
<วัตถุ> ชื่อ
<เอาท์พุท> ชื่อ
<พารามิเตอร์> ชื่อ
<select> ชื่อ
<textarea> ชื่อ

ตัวอย่าง

ตัวอย่าง

ปุ่มสองปุ่มที่มีชื่อเท่ากัน ซึ่งจะส่งค่าที่แตกต่างกันเมื่อคลิก:

<form action="/action_page.php" method="get">
  Choose your favorite subject:
  <button name="subject" type="submit" value="HTML">HTML</button>
  <button name="subject" type="submit" value="CSS">CSS</button>
</form>

ตัวอย่าง Fieldset

<fieldset> พร้อมแอตทริบิวต์ชื่อ:

<fieldset name="personalia">
  Name: <input type="text"><br>
  Email: <input type="text"><br>
</fieldset>

ตัวอย่างแบบฟอร์ม

แบบฟอร์ม HTML ที่มีแอตทริบิวต์ชื่อ:

<form action="/action_page.php" method="get" name="myForm">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="button" onclick="formSubmit()" value="Send form data!">
</form>

ตัวอย่างไอเฟรม

<iframe> ที่ทำหน้าที่เป็นเป้าหมายสำหรับลิงก์:

<iframe src="demo_iframe.htm" name="iframe_a"></iframe>

<a href="https://www.w3schools.com" target="iframe_a">W3Schools.com</a>

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

แบบฟอร์ม HTML ที่มีช่องป้อนข้อมูลสามช่อง ช่องข้อความสองช่องและปุ่มส่งหนึ่งปุ่ม:

<form action="/action_page.php">
  Name: <input type="text" name="fullname"><br>
  Email: <input type="text" name="email"><br>
  <input type="submit" value="Submit">
</form>

ตัวอย่างแผนที่

แผนผังรูปภาพพร้อมพื้นที่ที่สามารถคลิกได้:

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
  <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>

ตัวอย่าง Meta

ใช้แอตทริบิวต์ชื่อเพื่อกำหนดคำอธิบาย คำหลัก และผู้เขียนเอกสาร HTML:

<head>
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,JavaScript">
<meta name="author" content="Hege Refsnes">
</head>

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

<object> องค์ประกอบที่มีแอตทริบิวต์ชื่อ:

<object data="helloworld.swf" width="400" height="400" name="obj1"></object>

ตัวอย่างผลลัพธ์

ทำการคำนวณและแสดงผลใน <output> องค์ประกอบ:

<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
  <input type="range" id="a" value="50">100
  +<input type="number" id="b" value="50">
  =<output name="x" for="a b"></output>
</form>

ตัวอย่างพารามิเตอร์

ตั้งค่าพารามิเตอร์ "เล่นอัตโนมัติ" เป็น "จริง" เพื่อให้เสียงเริ่มเล่นทันทีที่หน้าโหลด:

<object data="horse.wav">
  <param name="autoplay" value="true">
</object>

เลือกตัวอย่าง

รายการแบบหล่นลงพร้อมแอตทริบิวต์ชื่อ:

<select name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

ตัวอย่างพื้นที่ข้อความ

พื้นที่ข้อความที่มีแอตทริบิวต์ชื่อ:

<form action="/action_page.php">
  <textarea name="comment">Enter text here...</textarea>
  <input type="submit">
</form>

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

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

Element
button Yes Yes Yes Yes Yes
fieldset Yes Not supported Yes Yes Yes
form Yes Yes Yes Yes Yes
iframe Yes Yes Yes Yes Yes
input 1.0 2.0 1.0 1.0 1.0
map Yes Yes Yes Yes Yes
meta Yes Yes Yes Yes Yes
object Yes Yes Yes Yes Yes
output 10.0 Not supported 4.0 5.1  11.0
param Yes Yes Yes Yes Yes
select Yes Yes Yes Yes Yes
textarea Yes Yes Yes Yes Yes