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

Comments: 2

profile
@niteshguptav63
17-Nov-2024, 01:39 PM

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

profile
@niteshguptav63
16-Nov-2024, 10:56 AM

When will I get my course?

profile
@admin79
17-Nov-2024, 01:29 PM

Now, Your query was resolved.

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?