API Reference
Add-HTMLStyle
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
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>]
#
All Parameter SetsParameters
- AddComment SwitchParameter
- Switch parameter to add comments around the added CSS styles.
- Content String[]
- Specifies an array of CSS content to be added directly to the HTML document.
- Css IDictionary
- Specifies a hashtable of CSS styles to be converted and added to the HTML document.
- FilePath String[]
- Specifies an array of file paths containing CSS content to be added to the HTML document.
- Link String[]
- Specifies an array of URLs to external CSS stylesheets to be linked in the HTML document.
- Placement String
- 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
- 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
- Specifies a hashtable of data to be replaced in the CSS content.
- Resource IDictionary
- Specifies the resource to be added as CSS styles.
- ResourceComment String
- Specifies a comment for the resource being added.
- SkipTags SwitchParameter
- Switch parameter to skip adding HTML tags when inserting CSS content.