การใส่ CSS แบบ Import File

wave
มานพ กองอุ่น 10 เม.ย. 2016 15:40:16 8,510

ไฟล์ที่เป็น CSS นั้น จะมีนามสกุล หรือ Extension เป็น .css ซึ่งโดยทั่วไปแล้วจะสร้างไฟล์ CSS แยกอิสระจากไฟล์ html เพื่อให้มีการจัดการได้ง่ายมากยิ่งขึ้น เช่น style.css
style.css

TAGNAME {
		attribute1 : value1;	
		attribute2 : value2;
		…
		attribute n : value n;
}
 


TAGNAME คือ Tag html ที่ไม่มี < >
attribute1, attribute2, …, attribute n คือ ชื่อรูปแบบ
value1, value2, …, value n คือ ค่าที่กำหนดให้รูปแบบ

page.html

<link rel= “stylesheet” type= “text/css” href= “style.css”>

ตัวอย่าง mystyle.css และ ex31.html
mystyle.css

B{
	color:red;
}


ex31.html

<html>
<head>
<title>CSS</title>
<link rel= “stylesheet" type= “text/css" href= “mystyle.css">
</head>
<body>
<b>Line1</b>
<b>Line2</b>
<b>Line3</b>
</body>
</html>

ผลลัพธ์


ความคิดเห็น

หากบทเรียนรู้มีความผิดพลาดประการใด หรือมีข้อเสนอแนะกรุณาแจ้ง contact@programmerthailand.com

เขียนบทเรียนรู้ของคุณ

รายละเอียด
  • ดู 8,510
  • รักเลย 0
  • หมวดหมู่ CSS
  • เขียนเมื่อ
  • แก้ไขเมื่อ
  • Tags css css3
ข้อมูลผู้เขียน
มานพ กองอุ่น

มานพ กองอุ่น

เป็นสมาชิกเมื่อ: 18 ธ.ค. 2009