CSS 7 ๐จ How To Borders
1. How to Create a Basic Border
Steps: Use border shorthand with width, style, and color
p {
border: 2px solid blue;
}
2. How to Set Border Width Only
Steps: Use border-width property with value
div {
border-width: 3px;
}
3. How to Set Border Style Only
Steps: Use border-style property with style type
span {
border-style: dashed;
}
4. How to Set Border Color Only
Steps: Use border-color property with color value
h1 {
border-color: red;
}
5. How to Create Different Border Styles
Steps: Apply various border styles to elements
.dotted { border: 2px dotted; }
.dashed { border: 2px dashed; }
.solid { border: 2px solid; }
.double { border: 4px double; }
.groove { border: 3px groove; }
.ridge { border: 3px ridge; }
.inset { border: 3px inset; }
.outset { border: 3px outset; }
6. How to Apply Border to Specific Sides
Steps: Use individual side properties
.box {
border-top: 2px solid green;
border-right: 1px dashed red;
border-bottom: 3px dotted blue;
border-left: 4px solid purple;
}
7. How to Set Top Border Only
Steps: Use border-top property
header {
border-top: 5px solid orange;
}
8. How to Set Right Border Only
Steps: Use border-right property
.sidebar {
border-right: 2px solid pink;
}
9. How to Set Bottom Border Only
Steps: Use border-bottom property
footer {
border-bottom: 3px solid teal;
}
10. How to Set Left Border Only
Steps: Use border-left property
.navigation {
border-left: 4px solid indigo;
}
11. How to Create Rounded Corners
Steps: Use border-radius property
.rounded-box {
border-radius: 10px;
}
12. How to Make Circular Border
Steps: Set large border-radius value
.circle {
border-radius: 50%;
width: 100px;
height: 100px;
}
13. How to Create Elliptical Border
Steps: Use different values for horizontal and vertical radius
.ellipse {
border-radius: 50px 20px;
width: 200px;
height: 100px;
}
14. How to Combine Multiple Borders
Steps: Apply multiple border properties together
.complex-border {
border-width: 3px 6px 9px 12px;
border-style: solid dashed dotted double;
border-color: red blue green yellow;
}
15. How to Create Border with Different Colors per Side
Steps: Use individual side properties with different colors
.multi-color {
border-top: 3px solid #ff0000;
border-right: 3px solid #00ff00;
border-bottom: 3px solid #0000ff;
border-left: 3px solid #ffff00;
}
16. How to Set Border with Transparent Color
Steps: Use transparent color value
.transparent-border {
border: 2px solid transparent;
background-color: lightgray;
}
17. How to Create Border with Gradient Effect
Steps: Use gradient as border color (with advanced techniques)
.gradient-border {
border: 3px solid;
border-image: linear-gradient(45deg, red, blue) 1;
}
18. How to Set Border to None
Steps: Use border: none to remove border
.no-border {
border: none;
}
19. How to Create Border with Inset Effect
Steps: Use inset border style
.inset-border {
border: 3px inset #ccc;
}
20. How to Create Border with Outset Effect
Steps: Use outset border style
.outset-border {
border: 3px outset #ccc;
}
21. How to Set Border Radius for Individual Corners
Steps: Use separate values for each corner
.individual-radius {
border-top-left-radius: 10px;
border-top-right-radius: 20px;
border-bottom-left-radius: 30px;
border-bottom-right-radius: 40px;
}
22. How to Create Border with Shadow Effect
Steps: Combine border with box-shadow
.shadow-border {
border: 2px solid black;
box-shadow: 0 0 5px rgba(0,0,0,0.3);
}
23. How to Set Border Width in Different Units
Steps: Use various units for border width
.unit-border {
border-width: 1em;
border-width: 2rem;
border-width: 5mm;
border-width: 10pt;
}
24. How to Create Border with Multiple Colors
Steps: Use different colors for different sides
.multi-color-sides {
border-top-color: red;
border-right-color: blue;
border-bottom-color: green;
border-left-color: yellow;
}
25. How to Set Border Style with Multiple Values
Steps: Apply multiple styles to one element
.multi-style {
border-width: 3px;
border-style: solid dashed dotted;
border-color: black;
}
26. How to Create Border with Animation
Steps: Animate border properties
.animated-border {
border: 3px solid #000;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { border-color: red; }
50% { border-color: blue; }
100% { border-color: red; }
}
27. How to Use Border with Background Color
Steps: Combine border and background properties
.combined {
border: 4px solid #333;
background-color: lightblue;
padding: 10px;
}
28. How to Create Border with Different Widths
Steps: Set different width values for each side
.different-widths {
border-top-width: 1px;
border-right-width: 2px;
border-bottom-width: 3px;
border-left-width: 4px;
}
29. How to Set Border with CSS Variables
Steps: Use CSS custom properties for border values
:root {
--border-width: 2px;
--border-style: solid;
--border-color: #ff0000;
}
.variable-border {
border: var(--border-width) var(--border-style) var(--border-color);
}
30. How to Create Border with Responsive Values
Steps: Use responsive units for borders
.responsive-border {
border: 2vw solid #333;
}
31. How to Set Border to Hidden
Steps: Use border: hidden property
.hidden-border {
border: hidden;
}
32. How to Create Border with Image Background
Steps: Use background image as border effect
.image-border {
border: 5px solid transparent;
background: url('pattern.png') repeat;
background-clip: border-box;
}
33. How to Apply Border to Specific Element States
Steps: Use pseudo-classes with borders
.link:hover {
border-bottom: 2px solid blue;
}
.button:focus {
border: 2px solid orange;
}
34. How to Create Border with Different Styles per Side
Steps: Apply different styles to each side
.different-styles {
border-top-style: solid;
border-right-style: dashed;
border-bottom-style: dotted;
border-left-style: double;
}
35. How to Set Border with Percentage Values
Steps: Use percentage values for border-radius
.percent-border {
border-radius: 25%;
width: 100px;
height: 100px;
}
36. How to Create Border with Inset/Outset Patterns
Steps: Combine inset/outset with other styles
.pattern-border {
border-top: 3px inset #ccc;
border-right: 3px outset #ddd;
border-bottom: 3px groove #eee;
border-left: 3px ridge #fff;
}
37. How to Use Border with Flexbox
Steps: Apply borders in flex container layouts
.flex-container {
display: flex;
}
.flex-item {
border: 2px solid black;
flex: 1;
}
38. How to Create Border with Box-Shadow Effect
Steps: Combine border with shadow effects
.shadow-effect {
border: 2px solid #000;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
39. How to Set Border with CurrentColor
Steps: Use current color for border
.current-color-border {
color: blue;
border: 2px solid currentColor;
}
40. How to Create Border with Multiple Layers
Steps: Stack multiple border effects
.multi-layer {
border: 10px solid #ff0000;
box-shadow: 0 0 0 5px #00ff00, 0 0 0 15px #0000ff;
}
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!