# New-HTMLAnchor

Creates a new HTML anchor element. 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`

Creates a new HTML anchor element.

## Syntax

```
New-HTMLAnchor
[[-Class] <String>]
[[-HrefLink] <String>]
[[-Id] <String>]
[[-Name] <String>]
[[-OnClick] <String>]
[[-Style] <IDictionary>]
[[-Target] <String>]
[[-Text] <String>]
[<CommonParameters>]
```

[#](#method-new-htmlanchor-string-string-string-string-string-idictionary-string-string)

Parameter set: `All Parameter Sets`

## Description

This function creates a new HTML anchor element (<a>) with specified attributes.

## Examples

### Example 1

```powershell
New-HTMLAnchor -Target _parent
Creates an anchor element with the target attribute set to "_parent".
```

New-HTMLAnchor -Id "show_$RandomNumber" -Href '#' -OnClick "show('$RandomNumber');" -Style "color: #ffffff; display:none;" -Text 'Show' Creates an anchor element with specified attributes and text.

Output: <a id="show_$RandomNumber" class="" target="_parent" href="#" onclick="show('$RandomNumber');" style="color: #ffffff; display:none;">Show</a>

## Parameters

**-Class String optionalposition: 3**

The CSS class of the anchor element.

**-HrefLink String optionalposition: 4aliases: Href, Link, Url, UrlLink**

The URL of the linked document.

**-Id String optionalposition: 1**

The ID of the anchor element.

**-Name String optionalposition: 0aliases: AnchorName**

The name of the anchor element.

**-OnClick String optionalposition: 5**

JavaScript code to execute when the anchor element is clicked.

**-Style IDictionary optionalposition: 6**

The CSS styles to apply to the anchor element.

**-Target String optionalposition: 2**

Specifies where to open the linked document.

**-Text String optionalposition: 7aliases: AnchorText, Value**

The text to display within the anchor element.

## 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:E5193F357E23440A5F9F46CC8193705DF64379AE27F882D6948B4765D3B8407C -->
