mdawar.dev

A blog about programming, Web development, Open Source, Linux and DevOps.

Style Links that Open in a New Tab Using CSS

Styling links that open in a new tab is a nice thing to add, this way the reader will know that a link will open in a new browser tab.

You can target these links using the CSS attribute selector:

css
1a[target='_blank'] {
2  /* Add your external link styles */
3}

You can also use the ::after pseudo-element to add an arrow, for example:

css
1a[target='_blank']::after {
2  content: '↗';
3}