xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to set color to different border lines of a div element using CSS
CSS Online Editor
Run Code
More CSS Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Set color to different border lines of div element using CSS</title> <!--Internal CSS added--> <style> /* CSS id name used to apply css style to the divs*/ #div-1 { border-top-color: red; /* border top color set to red*/ border-style: dashed; /* border style set to dashed*/ border-width: 2px; /* border width set to 2px*/ background-color: lightpink; /*background color of the div*/ min-height: 60px; /* minimum height of the div*/ } #div-2 { border-color: yellow black blue deeppink; /* different color for different border*/ border-style: solid; /* border style set to solid*/ border-width: 2px; /* border width set to 2px*/ background-color: lightblue; /*background color of the div*/ min-height: 60px; /* minimum height of the div*/ margin-top: 10px; /* margin at the top of div*/ } #div-3 { border-bottom: 2px dotted blue; /* bottom border set to 2 px dotted blue color*/ background-color: lightgreen; /*background color of the div*/ min-height: 60px; /* minimum height of the div*/ margin-top: 10px; /* margin at the top of div*/ } </style> </head> <body> <h1>How to set color to different border lines of div element using CSS?</h1> <div id="div-1">First Div with 2px dashed red color for top border</div> <div id="div-2">Second Div with different color for different border</div> <div id="div-3">Third Div with bottom border set to 2 px dotted blue</div> </body> </html>