HTML <บทความ>แท็ก
ตัวอย่าง
บทความสามบทความที่มีเนื้อหาอิสระและมีเนื้อหาในตัวเอง:
<article>
<h2>Google Chrome</h2>
<p>Google Chrome is a web browser
developed by Google, released in 2008. Chrome is the world's most popular web
browser today!</p>
</article>
<article>
<h2>Mozilla
Firefox</h2>
<p>Mozilla Firefox is an open-source web browser developed by
Mozilla. Firefox has been the second most popular web browser since January,
2018.</p>
</article>
<article>
<h2>Microsoft Edge</h2>
<p>Microsoft Edge is a web browser developed by Microsoft, released in 2015.
Microsoft Edge replaced Internet Explorer.</p>
</article>
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
แท็ ก<article>
ระบุเนื้อหาที่เป็นอิสระและมีอยู่ในตัวเอง
บทความควรมีความสมเหตุสมผลในตัวเอง และควรเผยแพร่แยกจากส่วนอื่นๆ ของไซต์ได้
แหล่งที่มาที่เป็นไปได้สำหรับ<article>
องค์ประกอบ:
- โพสต์ฟอรั่ม
- โพสต์บล็อก
- เรื่องข่าว
หมายเหตุ:องค์ประกอบ<article>
นี้จะไม่แสดงผลเป็นพิเศษในเบราว์เซอร์ อย่างไรก็ตาม คุณสามารถใช้ CSS เพื่อจัดรูปแบบ<article>
องค์ประกอบ (ดูตัวอย่างด้านล่าง)
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนองค์ประกอบอย่างสมบูรณ์
Element | |||||
---|---|---|---|---|---|
<article> | 6.0 | 9.0 | 4.0 | 5.0 | 11.1 |
คุณสมบัติสากล
แท็ ก<article>
ยังสนับสนุน Global Attributes ในHTML
คุณสมบัติของเหตุการณ์
แท็ ก<article>
ยังสนับสนุนแอตทริบิวต์เหตุการณ์ใน HTML
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ใช้ CSS เพื่อจัดรูปแบบ <article> องค์ประกอบ:
<html>
<head>
<style>
.all-browsers {
margin: 0;
padding: 5px;
background-color: lightgray;
}
.all-browsers
> h1, .browser {
margin: 10px;
padding: 5px;
}
.browser {
background: white;
}
.browser > h2,
p {
margin: 4px;
font-size: 90%;
}
</style>
</head>
<body>
<article class="all-browsers">
<h1>Most
Popular Browsers</h1>
<article class="browser">
<h2>Google Chrome</h2>
<p>Google Chrome is a web browser
developed by Google, released in 2008. Chrome is the world's most popular web
browser today!</p>
</article>
<article class="browser">
<h2>Mozilla Firefox</h2>
<p>Mozilla Firefox is an
open-source web browser developed by Mozilla. Firefox has been the second most
popular web browser since January, 2018.</p>
</article>
<article class="browser">
<h2>Microsoft Edge</h2>
<p>Microsoft Edge is a web browser developed by Microsoft, released in 2015.
Microsoft Edge replaced Internet Explorer.</p>
</article>
</article>
</body>
</html>
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML DOM: Article Object
การตั้งค่า CSS เริ่มต้น
เบราว์เซอร์ส่วนใหญ่จะแสดง<article>
องค์ประกอบด้วยค่าเริ่มต้นดังต่อไปนี้:
article {
display: block;
}