Evotec

Project

PSWriteHTML

PSWriteHTML is an open-source PowerShell project with packages, release history, and working documentation.

Stars 995
Forks 114
Open issues 69
PowerShell Gallery downloads 7,436,513
Release v1.41.0
Language: PowerShell Updated: 2026-04-11

API Reference

Function

ConvertTo-CascadingStyleSheets

Aliases: ConvertTo-CSS
Namespace PSWriteHTML
Aliases
ConvertTo-CSS

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

Remarks

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.

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.

Syntax

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

Parameters

Comment String optionalposition: 2pipeline: False
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: 1pipeline: False
Specifies the name of the CSS selector to be used in the stylesheet.
WithTags SwitchParameter optionalposition: namedpipeline: False
Indicates whether to include CSS style tags around the generated CSS content. Default is false.