# Borders

You can easily add borders to a paragraph in a Word document using DsWord. You can also get the border properties for a paragraph in the document.

## Content

DsWord allows you to specify the border properties for a paragraph using the [Border](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Border.html) class which can be accessed using [Borders](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ParagraphFormat.Borders.html) property of the [ParagraphFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ParagraphFormat.html) class.

## Get Borders

To get the borders of a paragraph:

1. Access a paragraph from the paragraph collection using [Paragraphs](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.RangeBase.Paragraphs.html) property of the [RangeBase](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.RangeBase.html) class.
2. Access the paragraph formatting properties using [Format](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Paragraph.Format.html) property of the [Paragraph](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Paragraph.html) class.
3. Get border collection of the paragraph using **Borders** property of the **ParagraphFormat** class.
4. Get the left and right borders using [Left](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BorderCollection.Left.html) and [Right](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BorderCollection.Right.html) properties of the [BorderCollection](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BorderCollection.html) class respectively.
5. Get the border style using [LineStyle](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Border.LineStyle.html) property of the [Border](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Border.html) class.
6. Get the border color using [Color](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Border.Color.html) property of the **Border** class.
7. Display the left and right border style and color on the console.

    ```csharp
    //Get borders
    LineStyle styleLeft = 
        doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.LineStyle;
    LineStyle styleRight = 
        doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.LineStyle;
    Color colorLeft = 
        doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.Color.RGB;
    Color colorRight = 
        doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.Color.RGB;
    Console.WriteLine("Left Border: " + styleLeft + " " + colorLeft);
    Console.WriteLine("Right Border: " + styleRight + " " + colorRight);
    ```

## Set Borders

To set the borders of a paragraph:

1. Access a paragraph from the paragraph collection using **Paragraphs** property of the RangeBase class.
2. Access the paragraph formatting properties using **Format** property of the Paragraph class.
3. Get border collection of the paragraph using **Borders** property of the ParagraphFormat class.
4. Get the left and right borders using **Left** and **Right** properties of the BorderCollection class respectively.
5. Set the border style using **LineStyle** property of the Border class.
6. Set the border color using **Color** property of the Border class.

    ```csharp
    //Set borders
    doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.Color.RGB = Color.Red;
    doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.LineStyle = 
        LineStyle.ChainLink;
    doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.Color.RGB = Color.Yellow;
    doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.LineStyle = 
        LineStyle.ChainLink;
    ```

For more information on how to implement paragraph borders using DsWord, see [DsWord sample browser](https://developer.mescius.com/documents-api-word/demos/).