Hard Rain Hard Rain - 1 month ago 6
HTML Question

How to create a new html element?

I tried to create a new HTML element, called test:

<test>some text</test>


I tried to prototyping it like this:
HTMLUnknownElement.prototype.style.backgroundColor = "red";
but it doesn't work.

Could you please help me, how to manage it?

Thanks in advance,

Answer

There isn't really a reason to do that.

When you want to create an element with red background, you should use an existing element and assign a CSS class to it which has red background (like <span class="test">) .