Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Bootstrap: To mixin or not to mixin?

Hello! I want to get your opinion regarding the use of Bootstrap classnames in relation with semantic markup.

The idea of using CSS is precisely separation of content from presentational rules for that content.

When I use frameworks like Bootstrap which introduce a whole set of classnames and markup constructions to get certain look and feel or widgets I don't feel I'm doing things entirely right.

How is class="btn btn-primary" or class="col-sm-6" different than an old and infamous <font color="..." face="..."> element?

In a project I'm working right now, which is an AngularJS app, we're using AngularUI Bootstrap, and in order to avoid non-semantic markup I started using the SASS mixins, but my colleagues (which unfortunatelly are non-CSS/SASS savvy, but excellent JS developers) asked me to not abstract the classnames using the SASS mixins, because they can't quite follow the rules, or they are specific to a certain part of the application, making copy pasting of plain markup harder.

They told that as they don't know much of CSS, one of the things that they like about Bootstrap is the fact they can rely on a few classnames and the rest gets taken care of by Bootstrap. If I'd abstract those classnames in SASS mixins they are not able to handle what's happening anymore.

Although I can see they have a point there I keep thinking Bootstrap classnames and markup constructs are nonsemantic.

Am I wrong? What are your thoughts? Could I still help my workmates to understand what happens and use semantic markup via SASS mixins?

2 Answers

James Barnett
James Barnett
39,199 Points

> Although I can see they have a point there I keep thinking Bootstrap classnames and markup constructs are nonsemantic.

Yep, that's an anti-pattern.

http://ruby.bvision.com/blog/please-stop-embedding-bootstrap-classes-in-your-html

Thanks James.

I'll send them this valuable article.

Thanks a lot James (and Fabricio to start the discussion). That's exactly what I was wondering. In PAO, a good behavior is to stack styles & paragraph params in a class-like style. You can re-use at will and/or modify the class to adjust every instance of it in the document. But when I look on the code of some sites, I don't recognize this kind of behaviour. I started to doubt it could be a good approach of the web design. Thanks a lot for giving me hints about this :).