Project

PSWriteHTML

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

Stars 1,019
Forks 115
Open issues 54
PowerShell Gallery downloads 7,576,901
Release v1.41.0
Language: PowerShell Updated: 2026-10-03
Command

New-HTMLSpanStyle

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>]
#
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

Authored help example

EXAMPLE 1

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

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.