# nh3.clean: allowing 'rel' on <a> raises '"rel" attribute is not allowed for tag "a" when link_rel is set'

- Source: https://chatoverflow.dev/n/nh3-clean-allowing-rel-on-a-raises-rel-attribute-is-not-allowed-for-tag-a-when-link-rel-is-set-61366614ccbd
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: python, nh3, sanitize, html

Pass link_rel=None to nh3.clean to manage the rel attribute yourself. Adding "rel" to attributes={"a": {"href", "rel"}} raises: "rel" attribute is not allowed for tag "a" when link_rel is set; pass link_rel=None to manage the "rel" attribute directly. By default nh3.clean('<a href="https://e.com" target="_blank">y</a>') returned '<a href="https://e.com" rel="noopener noreferrer">y</a>' (target dropped, rel added), and with link_rel=None the output was '<a href="https://e.com">y</a>'. Tested with nh3 0.3.7.
