# New-HTMLSpanStyle

Creates an HTML <span> element with specified styling.

Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

[View on GitHub](https://github.com/EvotecIT/PSWriteHTML) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteHTML/releases/tag/v1.41.0) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteHTML/1.40.0)

Stars **1,025**

Forks **114**

Open issues 

PowerShell Gallery downloads **7,576,901**

Release **v1.45.0**

Language: PowerShell Updated: 2026-11-19

Command 

**Module**

`PSWriteHTML`

Creates an HTML <span> element with specified styling.

## Syntax

```
New-HTMLSpanStyle
[[-Alignment] <left|center|right|justify>]
[[-BackGroundColor] <String>]
[[-Color] <String>]
[[-Content] <ScriptBlock>]
[[-Direction] <rtl>]
[[-Display] <String>]
[[-FontFamily] <String>]
[[-FontSize] <Object>]
[[-FontStyle] <normal|italic|oblique>]
[[-FontVariant] <normal|small-caps>]
[[-FontWeight] <String>]
[-LineBreak]
[[-LineHeight] <String>]
[[-Opacity] <Double>]
[[-TextDecoration] <line-through|overline|underline>]
[[-TextTransform] <uppercase|lowercase|capitalize>]
[<CommonParameters>]
```

[#](#method-new-htmlspanstyle-string-string-string-scriptblock-string-string-string-object-string-string-string-switchparameter-string-double-string-string)

Parameter set: `All Parameter Sets`

## Description

The New-HTMLSpanStyle function generates an HTML <span> element with customizable styling options such as color, background color, font size, font weight, font style, alignment, text decoration, text transformation, and more.

## Examples

### Example 1

```powershell
New-HTMLSpanStyle -Content { "Hello, World!" } -Color 'red' -FontSize '12px' -FontWeight 'bold' -Alignment 'center'
Creates a <span> element with red text, font size of 12 pixels, bold weight, and centered alignment containing the text "Hello, World!".
```

### Example 2

```powershell
New-HTMLSpanStyle -Content { "This is underlined text" } -Color 'blue' -TextDecoration 'underline'
Creates a <span> element with blue text and underlined decoration containing the text "This is underlined text".
```

## Parameters

**-Alignment String optionalposition: 9**

The alignment of the text within the <span> element.

Possible values: `left`, `center`, `right`, `justify`

**-BackGroundColor String optionalposition: 2**

The background color of the <span> element.

**-Color String optionalposition: 1**

The color of the text.

**-Content ScriptBlock optionalposition: 0**

The content to be placed within the <span> element.

**-Direction String optionalposition: 12**

The direction of the text.

Possible values: `rtl`

**-Display String optionalposition: 13**

The display style of the <span> element.

Possible values: `inline`, `block`, `inline-block`, `contents`, `flex`, `grid`, `inline-flex`, `inline-grid`, `inline-table`, `list-item`, `run-in`, `table`, `table-caption`, `table-column-group`, `table-header-group`, `table-footer-group`, `table-row-group`, `table-cell`, `table-column`, `table-row`

**-FontFamily String optionalposition: 8**

The font family to be used.

**-FontSize Object optionalposition: 3**

The font size of the text.

**-FontStyle String optionalposition: 6**

The style of the font.

Possible values: `normal`, `italic`, `oblique`

**-FontVariant String optionalposition: 7**

The variant of the font.

Possible values: `normal`, `small-caps`

**-FontWeight String optionalposition: 5**

The weight of the font.

Possible values: `normal`, `bold`, `bolder`, `lighter`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900`

**-LineBreak SwitchParameter optional**

Indicates whether to allow line breaks within the <span> element.

**-LineHeight String optionalposition: 4**

The height of each line of text.

**-Opacity Double optionalposition: 14**

The opacity of the <span> element.

**-TextDecoration String optionalposition: 10**

The decoration to be applied to the text.

Possible values: `line-through`, `overline`, `underline`

**-TextTransform String optionalposition: 11**

The transformation to be applied to the text.

Possible values: `uppercase`, `lowercase`, `capitalize`

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:BF0EB546809EC0E2C6349FB316874E5D8AE93ABC7F14AEFF469D1B7F402A705B -->
