As was previously mentioned, don't nest anchors inside buttons
, as it's not HTML5 compatible. In your case, since you're using Angular Material, it is ideal to do the following:
<a mat-raised-button color="primary" routerLink="/message-inbox">
Inbox
</a>
This creates an anchor tag that is styled like a button. This comes with all the benefits of a link:
- User can hover to preview link destination URL
- User can right-click, which opens up many options to work with the link (Open in new tab/window, Copy link address, etc.)
From the Angular Material Button docs:
Accessibility
Angular Material uses native <button>
and <a>
elements to ensure
an accessible experience by default. A <button>
element should be
used for any interaction that performs an action on the current page.
An <a>
element should be used for any interaction that navigates to
another URL. All standard accessibility best practices for buttons and
anchors apply to MatButton
.