TopBorder Class

Paragraph Border Above Identical Paragraphs.When the object is serialized out as xml, its qualified name is w:top.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlLeafElement
      DocumentFormat.OpenXml.Wordprocessing.BorderType
        DocumentFormat.OpenXml.Wordprocessing.TopBorder

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
Public Class TopBorder _
    Inherits BorderType
'Usage
Dim instance As TopBorder
public class TopBorder : BorderType

Remarks

[ISO/IEC 29500-1 1st Edition]

17.3.1.42 top (Paragraph Border Above Identical Paragraphs)

This element specifies the  border which shall be displayed above a set of paragraphs which have the same set of paragraph border settings.

To determine if any two adjoining paragraphs shall have an individual top and bottom border or a between border, the set of borders on the two adjoining paragraphs are compared. If the border information on those two paragraphs is identical for all possible paragraphs borders, then the between border is displayed. Otherwise, the final paragraph shall use its bottom border and the following paragraph shall use its top border, respectively. If this border specifies a space attribute, that value determines the space above the text (ignoring any spacing above) which should be left before this border is drawn, specified in points.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no between border shall be applied above identical paragraphs.

[Example: Consider the following two paragraphs' WordprocessingML definition:

<w:p>
  <w:pPr>
    <w:pBdr>
      <w:top w:val="single" w:sz="24" w:space="1" w:color="F2DCDB" w:themeColor="accent2" w:themeTint="33" /> 
      <w:left w:val="single" w:sz="24" w:space="4" w:color="B97034" w:themeColor="accent6" w:themeShade="BF" /> 
      <w:bottom w:val="single" w:sz="24" w:space="1" w:color="F2DCDB" w:themeColor="accent2" w:themeTint="33" /> 
      <w:right w:val="single" w:sz="24" w:space="4" w:color="C3D69B" w:themeColor="accent3" w:themeTint="99" /> 
      <w:between w:val="single" w:sz="24" w:space="1" w:color="4F81BD" w:themeColor="accent1" /> 
    </w:pBdr>
  </w:pPr>
  <w:r>
    <w:t>First paragraph.</w:t> 
  </w:r>
</w:p>
<w:p>
  <w:pPr>
    <w:pBdr>
      <w:top w:val="single" w:sz="24" w:space="1" w:color="F2DCDB" w:themeColor="accent2" w:themeTint="33" /> 
      <w:left w:val="single" w:sz="24" w:space="4" w:color="B97034" w:themeColor="accent6" w:themeShade="BF" /> 
      <w:bottom w:val="single" w:sz="24" w:space="0" w:color="F2DCDB" w:themeColor="accent2" w:themeTint="33" /> 
      <w:right w:val="single" w:sz="24" w:space="4" w:color="C3D69B" w:themeColor="accent3" w:themeTint="99" /> 
      <w:between w:val="single" w:sz="24" w:space="1" w:color="4F81BD" w:themeColor="accent1" /> 
    </w:pBdr>
  </w:pPr>
  <w:r>
    <w:t>Second paragraph.</w:t> 
  </w:r>
</w:p>

Since the paragraph border is different between the two paragraphs (the bottom space value goes from 1 to 0), paragraph two uses its top border, which is located one point above the text in that paragraph. end example]

Parent Elements

pBdr (§17.3.1.24)

This element’s content model is defined by the common border properties definition in §17.3.4.

[ISO/IEC 29500-1 1st Edition]

17.4.75 top (Table Cell Top Border)

This element specifies the border which shall be displayed at the top of the current table cell. The appearance of this table cell border in the document shall be determined by the following settings:

  • If the net tblCellSpacing element value (§17.4.45;§17.4.44;§17.4.46) applied to the cell is non-zero, then the cell border shall always be displayed

  • Otherwise, the display of the border is subject to the conflict resolution algorithm defined by the tcBorders element (§17.4.67) and the tblBorders element (§17.4.40;§17.4.39)

If this element is omitted, then the top of this table cell shall not have a cell border, and its border can use the table's border settings as appropriate.

[Example: Consider a table in which the first cell in the first row specifies a top cell border , as follows:

R1C1

R1C2

R2C1

R2C2

This top cell border is specified using the following WordprocessingML:

<w:tc>
<w:tcPr>
…
<w:tcBorders>
<w:top w:val="thinThickThinSmallGap" w:sz="24" w:space="0" w:color="FF0000"/>
</w:tcBorders>
</w:tcPr>
<w:p/>
</w:tc>

The top element specifies a three point border of type thinThinThickSmallGap. end example]

Parent Elements

tcBorders (§17.4.67)

This element’s content model is defined by the common border properties definition in §17.3.4.

[ISO/IEC 29500-1 1st Edition]

17.4.77 top (Table Top Border)

This element specifies the border which shall be displayed at the top of the current table. The appearance of this table border in the document shall be determined by the following settings:

  • The display of the border is subject to the conflict resolution algorithm defined by the tcBorders element (§17.4.67) and the tblBorders element (§17.4.40;§17.4.39)

If this element is omitted, then the top of this table shall have the border specified by the associated table style. If no top border is specified in the style hierarchy, then this table shall not have a top border.

[Example: Consider a table in which the table properties specifies a top table border, as follows:

R1C1

R1C2

R2C1

R2C2

This top table border is specified using the following WordprocessingML:

<w:tbl>
<w:tblPr>
<w:tblBorders>
<w:top w:val="thinThickThinMediumGap" w:sz="24" w:space="0" w:color="D0D0D0" w:themeColor="accent3" w:themeTint="99"/>
</w:tblBorders>
</w:tblPr>
…
</w:tbl>

The top element specifies a three point top table border of type thinThinThickMediumGap. end example].

Parent Elements

tblBorders (§17.4.39); tblBorders (§17.4.40)

This element’s content model is defined by the common border properties definition in §17.3.4.

[ISO/IEC 29500-1 1st Edition]

17.6.21 top (Top Border)

This element specifies the presentation and display of the page border displayed at the top of each page in this section.

[Example: Consider a section in which all pages must have a top border consisting of a repeated image of balloons, like this:

DocumentFormat.OpenXml.Wordprocessing.TopBorder-im

This border would result in the following WordprocessingML:

<w:sectPr>
…
<w:pgBorders>
<w:top w:val="balloons3Colors" …/>
</w:pgBorders>
…
</w:sectPr>

Because the page only has a border at the top, only the top element is specified within the set of page borders. end example]

When a document has a top border that is relative to the page edges (using an offsetFrom attribute value of page on pgBorders), it shall span the top edge of the page at the location defined by its properties, stopping when:

  • It intersects with the corresponding left or right page border (if one is specified)

  • It reaches the edge of the page.

[Example: In the example above, no left or right border was specified in the WordprocessingML, so a consumer must draw the border from one edge of the page to the other. end example]

When a document has a top border that is relative to the text (using the offsetFrom attribute value of text on pgBorders), it shall only span the necessary width to satisfy the requirement of spanning the width of the text.

When a document has custom border art specified by attributes topLeft, topRight, and/or id, it shall use the corresponding relationship part item as an image for the top left corner, top right corner, and/or top border, respectively. If the corresponding relationship part item cannot be resolved the consumer shall use the border specified by the value of the val attribute. If the corresponding value of the val attribute cannot be resolved no top left corner, top right corner, or top border is present when the page is displayed.

When a document has a custom border art specified by attribute id without specifying either attributes topRight and/or topLeft, the top border as resolved by the corresponding relationship part item of attribute id shall span to the corners not specified by topRight and/or topLeft attributes.

Parent Elements

pgBorders (§17.6.10)

Attributes

Description

color (Border Color)

Specifies the color for this border.

This value can be defined as either:

  • A color value using the RGB color model whose red, green, and blue values are written as numbers in the range 0 to 255, hex encoded, and concatenated. [Example: Full intensity red would be 255 red, 0 green, 0 blue, encoded to FF, 00, 00, and concatenated to FF0000. end example] . RGB colors are specified in the sRGB color space.

  • auto to allow a consumer to automatically determine the border color in order to make the document's text readable. [Example: A document with white text and a background color of auto might result in the use of a black background, in order to ensure legibility of the content. end example]

[Example: Consider a border color with value auto, as follows:

<w:bottom … w:color="auto"/>

This color therefore can be automatically be modified by a consumer as appropriate, for example, in order to ensure that the border can be distinguished against the page's background color. end example]

If the border style (the val attribute) specifies the use of an art border, this attribute is ignored. As well, if the border specifies the use of a theme color via the themeColor attribute, this value is superseded by the theme color value.

The possible values for this attribute are defined by the ST_HexColor simple type (§17.18.38).

frame (Create Frame Effect)

Specifies whether the specified border should be modified to create a frame effect by reversing the border's appearance from the edge nearest the text to the edge furthest from the text.

If this attribute is omitted, then the border is not given any frame effect.

[Example: Consider a bottom border which must appear with a frame effect, which is specified in the following WordprocessingML:

<w:bottom w:frame="true" … />

This frame's val is true, indicating that the border frame effect must be applied. end example]

The possible values for this attribute are defined by the ST_OnOff simple type (§22.9.2.7).

id (Custom Defined Border Relationship Reference)

Namespace: .../officeDocument/2006/relationships

Specifies the relationship ID for the relationship which contains the custom border image for the parent element. This custom border image is contained in a separate part within the WordprocessingML package.

The relationship explicitly targeted by this attribute shall be of type https://schemas.openxmlformats.org/officeDocument/2006/relationships/image or the document shall be considered non-conformant.

If this attribute is omitted, then no custom border shall be used.

[Example: Consider the following WordprocessingML markup for a custom bottom border in a document:

<w:bottom w:val="custom" r:id="rIdCustomBottomBorder" …/>

The id attribute in the relationship reference namespace specifies that the relationship with relationship ID rIdCustomBottomBorder must contain the custom bottom border image for the document. end example]

The possible values for this attribute are defined by the ST_RelationshipId simple type (§22.8.2.1).

shadow (Border Shadow)

Specifies whether this border should be modified to create the appearance of a shadow.

For the right and bottom borders, this is accomplished by duplicating the border below and right of the normal border location. For the right and top borders, this is accomplished by moving the order down and to the right of its original location.

If this attribute is omitted, then the border is not given the shadow effect.

[Example: Consider a top border which must appear with a shadow effect, resulting in the following WordprocessingML:

<w:bottom w:shadow="true" … />

This frame's val is true, indicating that the shadow effect must be applied to the border. end example]

The possible values for this attribute are defined by the ST_OnOff simple type (§22.9.2.7).

space (Border Spacing Measurement)

Specifies the spacing offset that shall be used to place this border on the parent object.

When a document has a page border that is relative to the page edges (using a value of page in the offsetFrom attribute on pgBorders (§17.6.10)), it shall specify the distance between the edge of the page and the beginning of this border in points.

When a document has a page border that is relative to the text extents (using a value of text in the offsetFrom attribute on pgBorders (§17.6.10)), or any other border type, it shall specify the distance between the edge of the object and the beginning of this border in points.

[Example: Consider a document with a set of page borders all specified to appear 24 points from the edge of the page. The resulting WordprocessingML would be as follows:

<w:pgBorders w:offsetFrom="page">
  <w:bottom … w:space="24" /> 
</w:pgBorders

The offsetFrom attribute specifies that the space value provides the offset of the page border from the page edge, and the value of the space attribute specifies that the page offset must be 24 points. end example]

The possible values for this attribute are defined by the ST_PointMeasure simple type (§17.18.68).

sz (Border Width)

Specifies the width of the current border.

If the border style (val attribute) specifies a line border, the width of this border is specified in measurements of eighths of a point, with a minimum value of two (one-fourth of a point) and a maximum value of 96 (twelve points). Any values outside this range can be reassigned to a more appropriate value.

If the border style (val attribute) specifies an art border, the width of this border is specified in measurements of points, with a minimum value of one and a maximum value of 31. Any values outside this range can be reassigned to a more appropriate value.

[Example: Consider a document with a three point wide dashed line border on all sides, resulting in the following WordprocessingML markup:

<w:top w:val="dashed" w:sz="24" …/>
<w:left w:val="dashed" w:sz="24" …/>
<w:bottom w:val="dashed" w:sz="24" …/>
<w:right w:val="dashed" w:sz="24" …/>

The border style is specified using the val attribute, and because that border style is a line border (dashed), the sz attribute specifies the size in eighths of a point (24 eighths of a point = 3 points). end example]

The possible values for this attribute are defined by the ST_EighthPointMeasure simple type (§17.18.23).

themeColor (Border Theme Color)

Specifies the base theme color used to generate the border color. The border color is the RGB value associated with themeColor as further transformed by themeTint or themeShade (if one is present), else the background color is the RGB value associated with themeColor.

The specified theme color is a reference to one of the predefined theme colors, located in the document's Theme part (§14.2.7 and §20.1.6.9), which allows color information to be set centrally in the document.

To determine the color to display, the following actions are performed:

  • Using the mapping specified in the ST_ThemeColor simple type (§17.18.97), the appropriate attribute on the clrSchemeMapping element (§17.15.1.20) is read.

  • Using that value and the mapping specified in the ST_ColorSchemeIndex simple type (§17.18.103), the appropriate element in the document’s Theme part is read to get the base theme color.

  • The specified color is modified based on the presence of the themeTint or themeShade attribute.

[Example: Consider a set of borders configured to use the accent2 theme color, resulting in the following WordprocessingML markup:

<w:top … w:themeColor="accent2" w:themeTint="99" />
<w:bottom … w:themeColor="accent2" w:themeTint="99" />
<w:left … w:themeColor="accent2" w:themeTint="99" />
<w:right … w:themeColor="accent2" w:themeTint="99" />

If the Settings part contained the following markup:

<w:clrSchemeMapping … w:accent2="accent2"/>

and the Theme part contained the following XML markup:

<a:accent2>
<a:srgbClr val="4F81BD"/>
</a:accent2>

the resulting border color would be 95B3D7 (the result of a 60% tint applied to the original theme color; see the calculations in themeTint below for details). end example]

The possible values for this attribute are defined by the ST_ThemeColor simple type (§17.18.97).

themeShade (Border Theme Color Shade)

Specifies the shade value applied to the supplied theme color (if any) for this border instance. If the themeColor attribute is not present, then this attribute shall not be used.

If the themeShade is supplied, then it is applied to the RGB value of the theme color (from the theme part) to determine the final color applied to this border.

The themeShade value is stored as a hex encoding of the shade value (from 0–255) applied to the current border.

[Example: Consider a shade of 40% applied to a border in a document. This shade is calculated as follows:

The resulting themeShade value in the file format would be 66. end example]

Given an RGB color defined as three hex values in RRGGBB format, the shade is applied as follows:

  • Convert the color to the HSL color format (values from 0 to 1)

  • Modify the luminance factor as follows:

  • Convert the resultant HSL color to RGB

[Example: Consider a document with a background using the accent2 theme color, whose RGB value (in RRGGBB hex format) is C0504D.

The equivalent HSL color value would be.

Applying the shade formula with a shade percentage of 75% to the luminance, we get:

Taking the resulting HSL color value of and converting back to RGB, we get 943634.

This transformed value can be seen in the resulting background's color attribute:

<w:top w:val="single" w:sz="4" w:space="24"
w:color="943634" w:themeColor="accent2"
w:themeShade="BF"/>

end example]

The possible values for this attribute are defined by the ST_UcharHexNumber simple type (§17.18.98).

themeTint (Border Theme Color Tint)

Specifies the tint value applied to the supplied theme color (if any) for this border instance. If the themeColor attribute is not present, then this attribute shall not be used.

If the themeTint is supplied, then it is applied to the RGB value of the theme color (from the theme part) to determine the final color applied to this border.

The themeTint value is stored as a hex encoding of the tint value (from 0–255) applied to the current border.

[Example: Consider a tint of 60% applied to a border in a document. This tint is calculated as follows:

The resulting themeTint value in the file format would be 99. end example]

Given an RGB color defined as three hex values in RRGGBB format, the shade is applied as follows:

  • Convert the color to the HSL color format (values from 0 to 1)

  • Modify the luminance factor as follows:

  • Convert the resultant HSL color to RGB

[Example: Consider a document with a background using the accent2 theme color, whose RGB value (in RRGGBB hex format) is 4F81BD.

The equivalent HSL color value would be.

Applying the tint formula with a tint percentage of 60% to the luminance, we get:

Taking the resulting HSL color value of and converting back to RGB, we get 95B3D7.

This transformed value can be seen in the resulting background's color attribute:

<w:top w:val="single" w:sz="4" w:space="24"
w:color="95B3D7" w:themeColor="accent2"
w:themeTint="99"/>

end example]

The possible values for this attribute are defined by the ST_UcharHexNumber simple type (§17.18.98).

topLeft (Custom Defined Top Left Border Relationship Reference)

Namespace: .../officeDocument/2006/relationships

Specifies the relationship ID for the relationship which contains the custom top left border image for the parent element. This custom border image is contained in a separate part within the WordprocessingML package.

The relationship explicitly targeted by this attribute shall be of type https://schemas.openxmlformats.org/officeDocument/2006/relationships/image or the document shall be considered non-conformant.

If this attribute is omitted, then no custom top left border shall be used.

[Example: Consider the following WordprocessingML markup for a custom top left border in a document:

<w:top w:val="custom" r:topLeft="rIdCustomTopLeftBorder" …/>

The id attribute in the relationship reference namespace specifies that the relationship with relationship ID rIdCustomTopLeftBorder must contain the custom top left border image for the document. end example]

The possible values for this attribute are defined by the ST_RelationshipId simple type (§22.8.2.1).

topRight (Custom Defined Top Right Border Relationship Reference)

Namespace: .../officeDocument/2006/relationships

Specifies the relationship ID for the relationship which contains the custom top right border image for the parent element. This custom border image is contained in a separate part within the WordprocessingML package.

The relationship explicitly targeted by this attribute shall be of type https://schemas.openxmlformats.org/officeDocument/2006/relationships/image or the document shall be considered non-conformant.

If this attribute is omitted, then no custom top left border shall be used when the parent element is instantiated.

[Example: Consider the following WordprocessingML markup for a custom top right border in a document:

<w:top w:val="custom" r:topRight="rIdCustomTopRightBorder" … />

The id attribute in the relationship reference namespace specifies that the relationship with relationship ID rIdCustomTopRightBorder must contain the custom top right border image for the document. end example]

The possible values for this attribute are defined by the ST_RelationshipId simple type (§22.8.2.1).

val (Border Style)

Specifies the style of border used on this object.

This border can either be an art border (a repeated image along the borders - shall only be used for page borders) or a line border (a line format repeated along the borders) - see the simple type definition for a description of each border style.

[Example: Consider a left border resulting in the following WordprocessingML:

<w:left w:val="single" …/>

This border's val is single, indicating that the border style is a single line. end example]

The possible values for this attribute are defined by the ST_Border simple type (§17.18.2).

[Note: The W3C XML Schema definition of this element’s content model (CT_TopPageBorder) is located in §A.1. end note]

[ISO/IEC 29500-1 1st Edition]

17.15.2.44 top (Top Border for HTML div)

This element specifies the border which shall be displayed at the top of the boundaries of the current HTML div object.

If this element is omitted, then this HTML div object shall not have a top border.

[Example: Consider a simple HTML document defined as follows:

<html>
<body>
<div style=" border-left-style:solid; border-right-style:groove; border-right-width:1px; border-top-style:dashed; border-top-width:3px; border-bottom-style:outset; border-bottom-width:3px">
<p>paragraph of text</p>
    </div>
</body>
</html>

This HTML would therefore normally appear as follows (image scaled appropriately):

DocumentFormat.OpenXml.Wordprocessing.TopBorder-im

Now, when this document is saved in the WordprocessingML format, the information stored on the div elements is stored in the web setting part as follows:

<w:divs>
<w:div w:id="1785730240">
…
<w:divBdr>
<w:top w:val="dashed" w:sz="18" w:space="7" w:color="auto" />
<w:left w:val="single" w:sz="24" w:space="4" w:color="auto" />
<w:bottom w:val="outset" w:sz="18" w:color="auto" />
<w:right w:val="threeDEngrave" w:sz="6" w:color="auto" />
</w:divBdr>
</w:div>
</w:divs>

The top element specifies border information about the top border for the single HTML div structure in the document; in this case, a 2.25 point bottom border of type dashed. The initial 3 pixel border was converted to 2.25 points using the following logic:

end example]

Parent Elements

divBdr (§17.15.2.7)

This element’s content model is defined by the common border properties definition in §17.3.4.

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

TopBorder Members

DocumentFormat.OpenXml.Wordprocessing Namespace