How to Add Border to an Element

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 46:- How to Add Border to an Element

You can add a border to an HTML element in CSS using the border property. The border property is a shorthand property that sets the width, style, and color of the border in one line of code.

Here's the basic syntax for adding a border:

cssCopy code

element {  border: width style color; }

  • width: the width of the border, in any CSS unit of measurement.
  • style: the style of the border, such as solid, dotted, double, groove, ridge, inset, or outset.
  • color: the color of the border, specified in any valid CSS color value format.

For example, to add a solid red border with a width of 5 pixels to a div element:

cssCopy code

div {  border: 5px solid red; }

You can also add a border to a specific side of an element using the border-top, border-right, border-bottom, and border-left properties. Each of these properties sets the border for a specific side of the element.

Here's an example of adding a blue dotted border to the top and bottom of a p element:

cssCopy code

p {  border-top: 2px dotted blue;  border-bottom: 2px dotted blue; }

6. Styling With CSS

2 Comments

@niteshguptav63
niteshguptav63 Nov 17, 2024 at 1:39 PM

I am not able to access videos from second class and further. I have already completed first class

@niteshguptav63
niteshguptav63 Nov 16, 2024 at 10:56 AM

When will I get my course?

@admin79
admin79 Nov 17, 2024 at 1:29 PM

Now, Your query was resolved.

Frequently Asked Questions About Sciaku Courses & Services

Quick answers to common questions about our courses, quizzes, and learning platform

Didn't find what you're looking for?

help_center Contact Support