CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



border-left

The border-left property is a CSS property that allows you to add a border to the left side of an HTML element. This property is used to create a visual separation between different sections of a webpage or to highlight a specific area of content.

The border-left property can be used to set the width, style, and color of the border. You can also use shorthand notation to set all of these properties at once.

Examples of Using Border-Left Property

Here are some examples of how to use the border-left property:

Example 1: Setting the Width, Style, and Color of the Border

To set the width, style, and color of the border, you can use the following syntax:

<div style="border-left: 2px solid red;">
  This is a div with a red border on the left side.
</div>

In this example, we have set the width of the border to 2 pixels, the style to solid, and the color to red.

Example 2: Using Shorthand Notation

You can also use shorthand notation to set all of the border properties at once. Here is an example:

<div style="border-left: 2px solid red;">
  This is a div with a red border on the left side.
</div>

In this example, we have set the width of the border to 2 pixels, the style to solid, and the color to red.

Example 3: Using Different Border Styles

You can use different border styles to create different effects. Here are some examples:

<div style="border-left: 2px dotted blue;">
  This is a div with a blue dotted border on the left side.
</div>

<div style="border-left: 2px dashed green;">
  This is a div with a green dashed border on the left side.
</div>

<div style="border-left: 2px double purple;">
  This is a div with a purple double border on the left side.
</div>

In these examples, we have used different border styles to create different effects. The first example uses a dotted border, the second example uses a dashed border, and the third example uses a double border.

Example 4: Using Different Border Widths

You can also use different border widths to create different effects. Here are some examples:

<div style="border-left: 1px solid black;">
  This is a div with a 1 pixel black border on the left side.
</div>

<div style="border-left: 3px solid black;">
  This is a div with a 3 pixel black border on the left side.
</div>

<div style="border-left: 5px solid black;">
  This is a div with a 5 pixel black border on the left side.
</div>

In these examples, we have used different border widths to create different effects. The first example uses a 1 pixel border, the second example uses a 3 pixel border, and the third example uses a 5 pixel border.

Conclusion

The border-left property is a useful CSS property that allows you to add a border to the left side of an HTML element. By using different border styles, widths, and colors, you can create a variety of effects to enhance the visual appeal of your webpage.

References

Activity