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

วิธีจัดข้อความให้อยู่กึ่งกลาง (Center) ใน HTML

แท็ก <center> ใช้จัดข้อความกึ่งกลาง แต่ deprecated แล้ว ควรใช้ CSS text-align: center; แทน

ตัวอย่าง (ไม่แนะนำ):

<!DOCTYPE html>
<html>
  <head>
    <title>HTML center Tag</title>
  </head>
  <body>
    <center>This text is centered</center>
    <p>This is a normal text.</p>
  </body>
</html>

วิธีที่แนะนำ: <p style="text-align: center;">Centered text</p>