Beniston Beniston - 1 year ago 131
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download