Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

เพิ่มข้อความจัดรูปแบบล่วงหน้า (Preformatted) ใน HTML


แท็ก <pre> ใช้สำหรับข้อความจัดรูปแบบล่วงหน้า (preformatted text) รักษาช่องว่าง, tab, line breaks ตรงตามที่พิมพ์ แสดงผลด้วยฟอนต์ monospace

ตัวอย่าง

<!DOCTYPE html> <html>    <head>       <title>HTML pre Tag</title>    </head>    <body>       <pre>          This text is          in a fixed-pitch          font, and it preserves          both spaces and line breaks       </pre>    </body> </html>

มักใช้ร่วมกับ <code> สำหรับโค้ดโปรแกรม: <pre><code>...</code></pre> เพื่อให้มีความหมายทาง semantics (code) และรูปแบบ (preformatted) พร้อมกัน