# ConvertTo-CascadingStyleSheets

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

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`

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

## Syntax

```
ConvertTo-CascadingStyleSheets
[[-Comment] <String>]
[[-Css] <IDictionary>]
[[-Name] <String>]
[-WithTags]
[<CommonParameters>]
```

[#](#method-convertto-cascadingstylesheets-string-idictionary-string-switchparameter)

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

### Example 1

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

```powershell
$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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:EA348487CBF9C82EC4BFBC890722ACD37CD47B87C03B39F3D81A6266D2044A61 -->
