คุณสมบัติ color
คุณสมบัติ color ใช้กำหนดสีของข้อความ ลองรันโค้ดต่อไปนี้เพื่อเรียนรู้การทำงานของคุณสมบัติ color ใน CSS:
ตัวอย่าง
<html>
<head>
</head>
<body>
<p style="color:blue;">
This text will be written in blue. </p>
</body>
</html>
รูปแบบสีที่รองรับ:
- ชื่อสี: red, blue, green, transparent
- HEX: #ff0000, #00ff00, #abcdef
- RGB/RGBA: rgb(255,0,0), rgba(255,0,0,0.5)
- HSL/HSLA: hsl(0,100%,50%), hsla(0,100%,50%,0.5)
คุณสมบัติ color ส่งผลต่อข้อความและขอบ (border) หากไม่ระบุสีขอบแยกต่างหาก