To my suprise, modern browser seem to not complain if I use custom tag names, and then style those tags as if it where normal html tags, they behave like span elements, and like div elements, if I set display: block;.
I mean, even if I don't use polymer, or try to register the custom element.
For example, I have this: https://jsfiddle.net/hvybz0nq/4/
<flex-fixed>
<sections>
<section>Section 1</section>
<section>Section 2</section>
<section>Section 3</section>
<div>Add Section</div>
</sections>
<splitter></splitter>
<pages>
<page>Page 1</page>
<page>Page 2</page>
<page>Page 3</page>
<div>Add Page </div>
</pages>
</flex-fixed>
With some css:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
flex-fixed, sections, section, div, pages, page {
display: flex;
}
body {
height: 100vh;
}
flex-fixed {
width: 100%;
height: 100%;
flex-direction: column;
position: fixed;
}
section {
border-right: 1px solid lightgrey;
}
splitter {
height: 1px;
background: lightgrey;
}
pages {
height: 100%;
border-left: 1px solid lightgrey;
align-self:flex-end;
flex-direction: column;
}
page {
border-bottom: 1px solid lightgrey;
}
section, page, div {
padding: 10px;
}
You absolutely can do this. It will work. Custom elements are part of the HTML5 spec; explicit support for unregistered custom elements is included (see section 7). They're supported in all modern browsers (by default they are treated as inline elements, just like <span>), there's first-class support for them in Angular.js for example. Functionally speaking there is no difference at all between <foo> and <span class="foo">.
So should you? I break it down like this:
Reasons not to use custom elements
document.createElement('foo').)<span class="foo"> does the same thing as <foo> without the tsurisReasons to use custom elements
On balance, I don't feel it's worth it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With