2

Is there any problem if I define my own HTML element in this way:

mynewelement {
  display: inline-block;
  border: 3px solid;
  border-color: red;
  background-color: pink;
  color: #000;
  padding: 4px;
}
<mynewelement>Hello World</mynewelement>

Will this lead to problems in the browser?

For me it works fine, no problems detected, but I worry it's not the right way to create a web element supported by all browsers. Is this incorrect? Or is this the same thing like any other html element(div, em, small, etc) and no difference?

Are all html elements made in this way?

Michael Armes
  • 1,056
  • 2
  • 17
  • 31
  • No, nothing bad or wrong creating your own elements, though the name maybe should be something more .... useful :) – Asons Nov 08 '16 at 22:48
  • http://stackoverflow.com/questions/2802687/is-there-a-way-to-create-your-own-html-tag-in-html5 – pol Nov 08 '16 at 22:49
  • 2
    There are a lot of questions in your question... which is pushing this into the "too broad" category. The main question here is a duplicate, of either the question mentioned by @JacobGray or [Are custom elements valid HTML5?](http://stackoverflow.com/q/9845011/215552) – Heretic Monkey Nov 08 '16 at 22:49
  • Not an issue but have a look at https://developer.mozilla.org/en-US/docs/Web/Web_Components/Custom_Elements for further details. Why are you creating your own element anyway? – Derek Nov 08 '16 at 22:50
  • without javascript i dont need javascript i want to use them without attributes like in my example –  Nov 08 '16 at 22:52

0 Answers0