# Add-HTMLStyle

Adds CSS styles to HTML documents. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteHTML API Reference.

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`

Adds CSS styles to HTML documents.

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

[#](#method-add-htmlstyle-switchparameter-string-idictionary-string-string-string-string-idictionary-idictionary-string-switchparameter)

Parameter set: `All Parameter Sets`

## Description

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

### Example 1

```powershell
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

```powershell
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

```powershell
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.

## Parameters

**-AddComment SwitchParameter optional**

Switch parameter to add comments around the added CSS styles.

**-Content String[] optionalposition: 4**

Specifies an array of CSS content to be added directly to the HTML document.

**-Css IDictionary optionalposition: 6aliases: CssInline**

Specifies a hashtable of CSS styles to be converted and added to the HTML document.

**-FilePath String[] optionalposition: 5**

Specifies an array of file paths containing CSS content to be added to the HTML document.

**-Link String[] optionalposition: 3**

Specifies an array of URLs to external CSS stylesheets to be linked in the HTML document.

**-Placement String optionalposition: 0**

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: 8**

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: 7**

Specifies a hashtable of data to be replaced in the CSS content.

**-Resource IDictionary optionalposition: 1**

Specifies the resource to be added as CSS styles.

**-ResourceComment String optionalposition: 2**

Specifies a comment for the resource being added.

**-SkipTags SwitchParameter optional**

Switch parameter to skip adding HTML tags when inserting CSS content.

## 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:1F174CFD3CD034D251193BFC4C167FB08CFF604E7D5DF77DCC1E6490A3154DE6 -->
