Say I have a cleaner like this
.cleaner:after { content: '.'; display: block; clear: both; visibility: hidden; height: 0; }
so I can add a class cleaner to everything that I want to clear floats. This imho is much better than adding
<div style="clear:both;"></div>
because in fact it does not separate the design from the markup.
But, although this approach can reduce some duplicates of the code, it also slightly violates the idea of โโshared design, because I need to directly modify the html.
Is it good to have classes like this and add them where necessary? Or should I explicitly add :after { ... to everything that I did not clear the float (for example, #header: after ..., #menu: after {.... `), which leads to duplication of code, but also a much more divided design where I donโt need to directly touch HTML.
A general-purpose class would probably be useful for javascript, where it would be easier to change styles, but duplicate code is worth the separate design effect in pure HTML / CSS?
html css
Jakub arnold
source share