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

ConvertTo-CascadingStyleSheets

Module PSWriteHTML

Converts a hashtable of CSS properties into Cascading Style Sheets (CSS) format.

Syntax

ConvertTo-CascadingStyleSheets [[-Comment] <String>] [[-Css] <IDictionary>] [[-Name] <String>] [-WithTags] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

The ConvertTo-CascadingStyleSheets function takes a hashtable of CSS properties and converts them into a CSS stylesheet format. It organizes the properties into selectors and declarations, ready to be used in styling HTML elements.

Examples

Authored help example

EXAMPLE 1

$CssProperties = @{
    'color' = 'blue'
    'font-size' = '16px'
    'font-family' = 'Arial'
}

ConvertTo-CascadingStyleSheets -Css $CssProperties -Name '.myClass' -Comment 'Custom styles for myClass'

Converts the hashtable of CSS properties into a CSS stylesheet with the selector '.myClass' and a custom comment.

EXAMPLE 2

$CssProperties = @{
    'background-color' = 'lightblue'
    'border' = @{
        'style' = 'solid'
        'width' = '1px'
        'color' = 'black'
    }
}

ConvertTo-CascadingStyleSheets -Css $CssProperties -Name '#myDiv' -WithTags

Converts the CSS properties into a CSS stylesheet with the selector '#myDiv' and includes CSS style tags.

Parameters

-Comment String optionalposition: 2
Specifies an optional comment to be included in the CSS stylesheet.
-Css IDictionary optionalposition: 0pipeline: True (ByValue, ByPropertyName)
Specifies the hashtable of CSS properties to be converted.
-Name String optionalposition: 1
Specifies the name of the CSS selector to be used in the stylesheet.
-WithTags SwitchParameter optional
Indicates whether to include CSS style tags around the generated CSS content. Default is false.

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.