Beniston Beniston - 9 months ago 81
HTML Question

CKEDITOR stripping the anchor tag inside a button

I have a piece of html code like this

<button class="login_btn"><a href="#">Login</a></button>

But when I apply CKEDITOR inline editor, it turns to

<button class="login_btn">Login</button>

I tried using

config.allowedContent = true;


config.extraAllowedContent = 'button(*){*};a(*){*};';

but the issue still persists. I do not want anything to be stripped.


CKEditor is stripping <a> from <button> because a <button> cannot contain an <a> element. Check your HTML with the HTML validator.

From the html5 button spec:

there must be no interactive content descendant.

And the interactive content page lists the anchor tag <a> as the first example.