🧱 CSS Borders

Style Your Web Elements with Beautiful Borders | GoNimbus

CSS borders allow you to frame your HTML elements with lines of various styles, widths, colors, and even shapes. Borders enhance visual structure, highlight content, and add design flair to your web pages.

Let’s explore how to use the CSS border properties effectively.


✨ What You’ll Learn:

  • border-style
  • border-width
  • border-color
  • Rounded borders (border-radius)
  • Applying borders to specific sides
  • Mixed borders

🖊️ 1. border-style

The border-style property defines the type of border to display. This is the most essential border property—without it, borders will not appear, even if other border properties are defined!

🎯 Syntax:

selector {
  border-style: value;
}

✅ Allowed Values:

  • dotted – Dotted line border
  • dashed – Dashed line border
  • solid – Solid line border
  • double – Two solid lines
  • groove – Carved effect (depends on color)
  • ridge – Opposite of groove
  • inset – Embedded look
  • outset – Pushed-out effect
  • none – No border
  • hidden – Hidden border

🧪 Example: Different Border Styles

p.dotted { border-style: dotted; }
p.dashed { border-style: dashed; }
p.solid { border-style: solid; }
p.double { border-style: double; }
p.groove { border-style: groove; }
p.ridge { border-style: ridge; }
p.inset { border-style: inset; }
p.outset { border-style: outset; }
p.none { border-style: none; }
p.hidden { border-style: hidden; }
p.mix { border-style: dotted dashed solid double; }

🎨 2. border-width

Defines how thick or thin your border is.

div {
  border-style: solid;
  border-width: 5px;
}

You can use specific values (like 1px, 10px) or keywords (thin, medium, thick).


🌈 3. border-color

Specifies the color of the border.

h2 {
  border-style: solid;
  border-color: blue;
}

You can use named colors, HEX, RGB, or RGBA values.


🎯 4. Border on Specific Sides

You can apply borders individually to the top, right, bottom, or left:

h3 {
  border-bottom: 2px solid red;
}

div {
  border-left: 4px solid blue;
}

🟣 5. Rounded Borders (border-radius)

Make elements look softer and more modern by rounding the corners.

button {
  border: 2px solid green;
  border-radius: 10px;
}

You can control each corner individually or use a single value.


🧩 6. Shorthand Property

To simplify your code, use the shorthand border:

p {
  border: 2px dashed purple;
}

This is equivalent to:

p {
  border-width: 2px;
  border-style: dashed;
  border-color: purple;
}

📌 Important Note

🚫 No border will appear unless border-style is defined. Even if you set border width and color, they won’t apply unless the style is set!


🔁 Summary Table

PropertyDescription
border-styleDefines the type of border
border-widthSets the thickness of the border
border-colorDefines the border’s color
border-radiusRounds the corners of an element
borderShorthand for style, width, and color

🚀 Hands-on Practice with GoNimbus

Try experimenting with different borders directly in your GoNimbus editor. See how changing the style, width, and radius gives your elements a polished and professional look!


Scroll to Top