คุณสมบัติเส้นขอบ CSS ใช้เพื่อกำหนดคุณสมบัติเส้นขอบสำหรับองค์ประกอบ มันเป็นชวเลขสำหรับความกว้างของเส้นขอบ สไตล์เส้นขอบ และสีเส้นขอบ เราสามารถจัดรูปแบบแต่ละด้านโดยใช้คุณสมบัติเฉพาะด้าน เช่น ขอบบน ขอบขวา ฯลฯ
ไวยากรณ์
ไวยากรณ์ของคุณสมบัติเส้นขอบ CSS มีดังต่อไปนี้ -
Selector {
border: /*value*/
} ตัวอย่าง
ตัวอย่างต่อไปนี้แสดงให้เห็นถึงคุณสมบัติเส้นขอบ CSS -
<!DOCTYPE html>
<html>
<head>
<style>
div {
border-style: solid;
margin: auto;
padding: 5px;
border-radius: 50%;
}
#main {
height: 100px;
width: 100px;
border-left: 12px ridge goldenrod;
border-right: 12px ridge goldenrod;
}
#main > div {
line-height: 12px;
height: 30px;
width: 10px;
padding: 27px 20px;
border-top: 6px groove crimson;
border-bottom: 6px ridge crimson;
}
</style>
</head>
<body>
<div id="main">
<div>i see you</div>
</div>
</body>
</html> ผลลัพธ์
สิ่งนี้ให้ผลลัพธ์ต่อไปนี้ -

ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
p {
width: 60%;
margin: auto;
padding: 20px 45px;
border-top-width: 1.4em;
border-top-style: solid;
border-top-color: violet;
border-radius: 85px 85px 0 0;
color: black;
font-size: 1.3em;
background-image: url("https://www.tutorialspoint.com/images/css.png");
}
</style>
</head>
<body>
<p>CSS is used to control the style of a web document in a simple way. It handles the look and feel part of a web page.</p>
</body>
</html> ผลลัพธ์
สิ่งนี้ให้ผลลัพธ์ต่อไปนี้ -
