วางกฎ CSS ในเอกสาร HTML โดยใช้แอตทริบิวต์ <style> เรียกว่า Embedded CSS แท็กนี้วางภายใน <head>...</head> กฎที่กำหนดด้วย syntax นี้จะใช้กับทุกองค์ประกอบในเอกสาร
ตัวอย่าง Embedded CSS:
<!DOCTYPE html>
<html>
<head>
<style media="all">
body {
background-color: orange;
}
h1 {
color: yellow;
margin-left: 30px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>แอตทริบิวต์:
| แอตทริบิวต์ | ค่า | คำอธิบาย |
|---|---|---|
| Type | text/css | ระบุภาษา style sheet เป็น content-type (MIME type) จำเป็น |
| media | screen, tty, tv, projection, handheld, print, braille, aural, all | ระบุอุปกรณ์แสดงผล ค่าเริ่มต้น all ไม่บังคับ |