"About HTML semantics and front-end architecture" (from March 2012):
http://nicolasgallagher.com/about-html-semantics-front-end-a...
It's all well worth reading, but the conclusion is particularly to the point:
"The experience of many skilled developers, over many years, has led to a shift in how large-scale website and applications are developed. Despite this, for individuals weaned on an ideology where “semantic HTML” means using content-derived class names (and even then, only as a last resort), it usually requires you to work on a large application before you can become acutely aware of the impractical nature of that approach. You have to be prepared to disgard old ideas, look at alternatives, and even revisit ways that you may have previously dismissed.
...
When you choose to author HTML and CSS in a way that seeks to reduce the amount of time you spend writing and editing CSS, it involves accepting that you must instead spend more time changing HTML classes on elements if you want to change their styles. This turns out to be fairly practical, both for front-end and back-end developers – anyone can rearrange pre-built “lego blocks”; it turns out that no one can perform CSS-alchemy."
Also, laziness is one of the three great virtues of a programmer according to Larry Wall. People are getting things done with Bootstrap every day.
Abstractions still require names, and the names should be meaningful (not easy: "naming things is one of the hardest things to do in software development"), at least to the development team (hate to keep rattling off platitudes, but "you should write code for humans first, computers second"). Rather than "semantic", "descriptive" seems to fit the bill.
"Abstract and descriptive". Doesn't quite roll off the tongue, but I tried :)
(paper - http://www.balisage.net/Proceedings/vol10/html/Usdin01/Balis...)
SEO doesnt care , users dont care, accessibility doesnt care either. Using new HTML5 tags is good enough and was designed for that specific purpose. If i want semantics I use nav,aside,section instead of div,and so on.
Not going to waste my time and wrap bootstrap mixins in more LESS mixins and loose theme portability and modularity,because semantics...
It's like inobstrusive javascript, trends that make little sense today in the webapp era.
Also, if you are providing a theme, I don't see how you lose portability. Your mixins will be relying on base bootstrap anyway?
For me it's about being in control of the situation. I will find myself changing things just for them to look as they are supposed to look like, and soon realizing that is not CSS anymore, just another framework being in between and making the work sometimes easier and sometimes harder. Using LESS at least gives you a bit more of control on the hidden spots, and opens room for sane customization.
I do personally prefer to not use a CSS framework at all, but if Bootstrap is a requisite on a project, using LESS is a no brainer.
Every non-semantic bootstrap site I've seen has far more templates than would be necessary the templates only spit out minimal markup with classes that say what each element is instead of what it looks like.
But now we have tons of developers whose primary skill is backend development that are able to mash together a reasonable looking site without understanding how to create maintainable front end code. When the design changes, they just keep piling on more markup and more classes. This works for a while, but as designs get iteratively tweaked and changed, and kludges pile on top of kludges, the markup and CSS become a huge tangled mess. Making changes can have unpredictable effects on other parts of the site.
And then the back end developers throw up their hands and say, "CSS is stupid." But users don't care if the code is a mess, right? Machines don't care either. But the front end dev -- the one who's tasked with getting the new design to work without breaking anything else on the site -- he cares. And he's gonna have a bad time.
Anyone who has used Bootstrap's mixins with semantics in mind knows there are some bigger issues to address than the layout. Some questions off the top of my head:
* How do you build semantic forms with Bootstrap without going to markup fluff hell?
* How can you avoid the unsemantic class names for components that are tied too closely with child components (I'm looking at you, .panel)?
* What is the semantic purpose of a row element? It seems purely presentational to me.
* How do I add icons without peppering span.glyphicon.glyphicon-X's all over my markup?
* How should I organize/maintain all of my LESS files as my stylesheets scale? I'm not looking for any one "right" way, but suggestions are always nice.
* Are there any optimizations I can consider when I'm only using a bit of Bootstrap's functionality?
* How can I extend Bootstrap's mixins for my own needs?
* How do I add icons without peppering span.glyphicon.glyphicon-X's all over my markup?
This one's fairly simple--you still need to add a class to the span, but you can extend the glyphicon.glyphicon-X bit into a particular icon and call it a day:
.foo-icon {
&:extend(.glyphicon);
&:extend(.glyphicon-foo);
}
* How should I organize/maintain all of my LESS files as my stylesheets scale?I'm not sure there is a "right" way, but I'd suggest keeping like things together. You're going to end up with a number of rules that are either dependent upon each other, or at least similar in goal, and they can live near each other. In theory, future refactorings will be easier that way.
* Are there any optimizations I can consider when I'm only using a bit of Bootstrap's functionality?
http://getbootstrap.com/customize/
^ Do that :)
Good luck. If you find answers to the rest of those questions, pass them to me!!
question 5: I'll usually put bootstrap into its own folder, have a style.less outside of the folder that imports bootstrap.less, import stylesheets with custom mixins after bootstrap.less, and import straight up custom styles after that.
question 6: go into bootstrap.less and comment out the stuff you're not using. For the js, use something like gulp-include to concatenate.'
question 7: Load my-mixins.less after bootstrap.less, copy and paste mixins from bootstrap into there, and modify them.
<section>
<main> </main>
<aside> </aside>
<section> main > section > main
just main.semantic-class <section class="body">
<main class="content"></main>
<aside class="sidebar"></aside>
</section> main
> section
> main
text-decoration blink
Thus, things that are easy to change in HTML structure (cutting, pasting, and changing indentation) are similarly easy to change in CSS.As demonstrated in the article you can trivially make an element 6 columns in LESS (or SASS, which has a bootstrap port also)
i.e. if you have:
.column {
width: 100px;
display: inline-block;
}
And you do: .cool-sidebar {
@extend .column;
}
Then the generated css will be something like: .column, .cool-sidebar {
width: 100px;
display: inline-block;
}
[1] https://github.com/twbs/bootstrap-sassPerhaps if I were building a CMS or some other document-oriented site I would approach things differently.
.make-column(@large, @medium, @small, @tiny: 12) { .make-xs-column(@tiny); .make-sm-column(@small); .make-md-column(@medium); .make-lg-column(@large); }
Then use it with: section#main-content { .make-column(8,8,9,12); }
Build the CSS for your next project using mixin libraries like Bourbon/Neat or Compass/Susy. You'll be glad you did.
I believe initially Bootstrap was intended for just this use case—make it easier to do a quick mock-up in markup. Once your design is relatively stable, you would naturally spend some time custom-fitting markup and stylesheets (enhancing source code readability, accounting for those who can't see, basic SEO optimization, etc.). This whole ‘front-end framework’ thing seems to me like a wrong direction to take.
But you know what's worse than Bootstrap? The hand-rolled framework that rises out of the muck on a large project. At least Bootstrap is always the same. It's a lingua franca, and a decent one at that.
I also agree with the idea that we should use Mixins to allow for more semantic meaning in our plain HTML. As an added bonus, this can make things a lot more maintainable down the road.
If you try this with the method outlined by the OP, you'll end up with a giant css file.
Kolega, use parametric mixins without parameters: http://lesscss.org/features/#mixins-parametric-feature
For unused css I'd try this: https://github.com/addyosmani/grunt-uncss