I am playing around with creating my own framework where I inject content into ‘custom elements’ (I am not sure how to refer to them correctly .. they are not custom elements as they are not web components)
Is there a way to correctly put styles on html elements that are not part of the standard ? I can’t see why ie border or float can’t work ? the debugger seems to show that the browser correctly calculates their size.
For example the following give a strange result 🙁
<style>
.border { border:solid }
</style>
<custom- class="border">
<div>
hello
</div>
</custom->
2
Answers
You can can create your own custom elements in HTML, but they are
display: inline
by default, so (depending on the result you want) you may have to specify a particular display (e.g.display: block
) to get the result you want.The default
display
property for your element isinline
, so it’s not calculating the width properly based on the contained div.Changing it to
inline-block
orblock
makes it work as desired.