Using <a> inside of <a>
Answered
Yellowhead catfish posted this in #help-forum
Yellowhead catfishOP
Am I not allowed to use an <a> element inside of another <a> element? It renders fine, but I get these errors from Next.JS
<a
className="flex flex-col p-6 rounded-xl w-[90vw] md:w-full md:max-w-sm md:min-h-52 border border-white/[0.2]
hover:border-white/[0.3] hover:-translate-y-2 duration-500"
href={link}
>
<a href={link2}>
<IconBrandGithub className="brightness-50 absolute rounded-full ml-[17.25rem] -translate-y-4 hover:scale-105 hover:brightness-100 duration-500"/>
</a>
<img className="rounded-full " src={image} alt="" width={100} height={100}/>
<h1 className="mt-2 text-xl font-bold">{title}</h1>
<p className="mt-1 text-sm text-neutral-500">{description}</p>
</a>
Answered by Rafael Almeida
I had a few designs where a clickable element would contain a smaller element that should also be a link, in this case the fix would be to render them wrapped by a div and move the "nested" element on top of the first element
9 Replies
nested anchor tags is invalid HTML: https://stackoverflow.com/a/18667146
Yellowhead catfishOP
well thats dumb
@Rafael Almeida nested anchor tags is invalid HTML: https://stackoverflow.com/a/18667146
Yellowhead catfishOP
how else can i do it then?
and why does it work fine
the logic of the browser is to always try to render the document regardless of issues in the markup to avoid breaking websites, this is why initially it works
but React will try to avoid the mistake by throwing an error during hydration
all you need to do is to fix the HTML
I had a few designs where a clickable element would contain a smaller element that should also be a link, in this case the fix would be to render them wrapped by a div and move the "nested" element on top of the first element
Answer
Yellowhead catfishOP
alright