Live data from Hacker News

Using Bootstrap the Semantic Way

ostraining.com

11–20 of 71 posts

Re: Using Bootstrap the Semantic Way

#11
post #4

What are current options to optimize LESS files and remove unused mixins? And for the generated CSS, what are current options to merge shared rules and remove unused classes reported against a sample HTML?

>What are current options to optimize LESS files and remove unused mixins?

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

Re: Using Bootstrap the Semantic Way

#12
This is one of the main reasons I like AngularJS directives. If used properly (huge caveat) they allow your template markup to take on far more semantic meaning.

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.

Re: Using Bootstrap the Semantic Way

#13
post #3

The point of using bootstrap is a reusable set of classes. I really dont care wether class names are semantic or not,it doesnt change anything,except for pedantic people looking at your source code. 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. No…

Couldn't disagree more with your statement. What if you have a sidebar that appears 20+ times throughout your application in different contexts. You might decide it is too wide. Are you going to go through all your templates and change class="col-md-blah" or are you going to change one mixin?

Also, if you are providing a theme, I don't see how you lose portability. Your mixins will be relying on base bootstrap anyway?

Re: Using Bootstrap the Semantic Way

#15
post #3

The point of using bootstrap is a reusable set of classes. I really dont care wether class names are semantic or not,it doesnt change anything,except for pedantic people looking at your source code. 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. No…

This sounds exactly like the complaints lodged against structured programming[1] by traditional GOTO-based programmers.

1. https://en.wikipedia.org/wiki/Structured_programming

Re: Using Bootstrap the Semantic Way

#16
post #7
post #3

The point of using bootstrap is a reusable set of classes. I really dont care wether class names are semantic or not,it doesnt change anything,except for pedantic people looking at your source code. 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. No…

You will start caring the day you want to update to Bootstrap 9000 and need to change the class names of all the properties that have changed. A counterargument could be that one could stick with the version already deployed, and that's fine too I guess. 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 t…

Bootstrap already depends on the markup structure, which makes your point moot.

Re: Using Bootstrap the Semantic Way

#17
post #3

The point of using bootstrap is a reusable set of classes. I really dont care wether class names are semantic or not,it doesnt change anything,except for pedantic people looking at your source code. 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. No…

Couldn't disagree more with your statement. What if you have a sidebar that appears 20+ times throughout your application in different contexts. You might decide it is too wide. Are you going to go through all your templates and change class="col-md-blah" or are you going to change one mixin? Also, if you are providing a theme, I don't see how you lose portability. Your mixins will be relying on base bootstrap anyway…

This is what is great about decorators (the most awesome part of Web Components that probably will never be implemented):

http://www.w3.org/TR/components-intro/#decorator-section

Re: Using Bootstrap the Semantic Way

#18
We do div soup because CSS is still not good enough to do all of your styling there. When you can trivially make an element 6 columns in CSS we'll all stop treating Bootstrap like this. Maybe Flexbox version 6 (or whatever we are on now) finally fixes this but who can keep up and find out.

Re: Using Bootstrap the Semantic Way

#19
Still the most comprehensive rebuttal to this common (and I feel, badly mistaken) complaint:

"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."

Re: Using Bootstrap the Semantic Way

#20
post #9

I appreciate the comparison to the ancient Web, but this article doesn't say much more that I can't find in Bootstrap's documentation. 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 c…

I'm hardly a pro at using bootstrap, but we have been dealing with a few of these things, and I can tell you how we've handled some of these questions:

* 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!!

Post reply on HN