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

Add-HTMLStyle

Aliases: Add-CSS
Namespace PSWriteHTML
Aliases
Add-CSS

Adds CSS styles to HTML documents.

Remarks

The Add-HTMLStyle function allows you to add CSS styles to HTML documents in various ways such as inline styles, external stylesheets, and content from files or strings.

Examples

Authored help example

EXAMPLE 1


Add-HTMLStyle -Placement 'Header' -Resource 'styles.css' -ResourceComment 'Custom styles' -Link 'https://example.com/styles.css'
        

Adds a linked CSS stylesheet to the header of the HTML document with a custom comment.

EXAMPLE 2


Add-HTMLStyle -Placement 'Inline' -Content 'body { background-color: lightblue; }' -ResourceComment 'Inline styles'
        

Adds inline CSS styles directly to the HTML document body with a custom comment.

EXAMPLE 3


Add-HTMLStyle -Placement 'Footer' -Css @{ 'body' = @{ 'background-color' = 'lightblue' } } -ResourceComment 'Custom CSS'
        

Converts a hashtable of CSS styles to a stylesheet and adds it to the footer of the HTML document with a custom comment.

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

Add-HTMLStyle [-AddComment] [-Content <String[]>] [-Css <IDictionary>] [-FilePath <String[]>] [-Link <String[]>] [-Placement <Inline|Header|Footer>] [-RelType <dns-prefetch|preconnect|preload>] [-ReplaceData <IDictionary>] [-Resource <IDictionary>] [-ResourceComment <String>] [-SkipTags] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

AddComment SwitchParameter optionalposition: namedpipeline: False
Switch parameter to add comments around the added CSS styles.
Content String[] optionalposition: 4pipeline: False
Specifies an array of CSS content to be added directly to the HTML document.
Css IDictionary optionalposition: 6pipeline: Falsealiases: CssInline
Specifies a hashtable of CSS styles to be converted and added to the HTML document.
FilePath String[] optionalposition: 5pipeline: False
Specifies an array of file paths containing CSS content to be added to the HTML document.
Link String[] optionalposition: 3pipeline: False
Specifies an array of URLs to external CSS stylesheets to be linked in the HTML document.
Placement String optionalposition: 0pipeline: Falsevalues: 3
Specifies where the CSS styles should be placed in the HTML document. Valid values are 'Inline', 'Header', or 'Footer'. Default is 'Header'.
Possible values: Inline, Header, Footer
RelType String optionalposition: 8pipeline: Falsevalues: 3
Specifies the relationship type for linked stylesheets. Valid values are 'dns-prefetch', 'preconnect', or 'preload'. Default is 'preload'.
Possible values: dns-prefetch, preconnect, preload
ReplaceData IDictionary optionalposition: 7pipeline: False
Specifies a hashtable of data to be replaced in the CSS content.
Resource IDictionary optionalposition: 1pipeline: False
Specifies the resource to be added as CSS styles.
ResourceComment String optionalposition: 2pipeline: False
Specifies a comment for the resource being added.
SkipTags SwitchParameter optionalposition: namedpipeline: False
Switch parameter to skip adding HTML tags when inserting CSS content.