HTML - DOM Style Object borderLeft Property



HTML DOM Style Object borderLeft property sets or returns the left border properties of an element. It is a shorthand notation for border-left-width, border-left-style and border-left-color.

Syntax

Given below are the syntax to get or set the borderLeft property.

Set the borderLeft property:
object.style.borderLeft= "width | style | color | initial | inherit";
Get the borderLeft property:
object.style.borderLeft;

Property Values

Value Description
width It sets the left border width.
style It sets the left border style.
color It sets the left border color.
initial It is used to set this property to it's default value.
inherit It is used to inherit the property of it's parent element.

Return Value

It returns a string value which represents left border width, style and color property of an element.

Example of HTML DOM Style Object 'borderLeft' Property

The following example sets a left border to a section element.

<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOM Style Object borderLeft Property
    </title>
</head>
<body>
    <button onclick="fun()">
        Add left Border
    </button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
            .style.borderLeft = "4px dashed #04af2f";
        }
    </script>
</body>
</html>

Supported Browsers

Property Chrome Edge Firefox Safari Opera
borderLeft Yes 1 Yes 12 Yes 1 Yes 1 Yes 3.5
html_dom.htm
Advertisements