Re:Templating in HTML
by Stamp01 on Tuesday October 04, 2022 @06:23PM
(#33087922)
I think the main advantages are that you don't have to remember to add "display:none", and that it gives the structure more semantic meaning. If I look at your code and see "display:none", I don't know why you've chosen to hide it. If it's wrapped in a <template> element, I instantly know why it's not being displayed as I now have an idea of how it's going to be used.
[ Parent
| on HN ]
Re:Templating in HTML
by galaxyLogic on Wednesday October 05, 2022 @01:01AM
(#33091465)
Yes but when you see "display:none;" isn't it obvious that the purpose is to make it visible sometime later?
Also if you need to use the same HTML elsewhere, just copy the innerHTML of such an element and insert anywhere you want to.
> Yes but when you see "display:none;" isn't it obvious that the purpose is to make it visible sometime later?
Yes, but it's not obvious that it would be made visible in a different place while keeping the original invisible.
Re:Templating in HTML
by forgotusername6 on Wednesday October 05, 2022 @01:59AM
(#33091824)
Hidden forms are an example of display:none that will not be displayed later