This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 15k traffic Daily!!!

BEM, CSS Namespaces and ITCSS

as a result of writing CSS is simple; taking care of it’s not.


Sure, although currenly there are many instruments concerned in CSS panorama these days, it is a fairly straightforward language to begin with, and attributable to its design (pitfalls ?) it is also fairly straightforward to search out your self quickly losing time on deciding courses names and struggling to make your code extra maintainable and scalable.

Mainly HTML and CSS shares courses (and ids) to form the ultimate UI and reusing courses being certain to do precisely what you need, the place you need, with out introducing issues in a very totally different a part of the ui requires you, developer, to be actually correct/diligent.

Methodologies, naming conventions and architectures assist you numerous.

That is what’s at present serving to me so much.


Block Aspect Modifier is a methodolgy, or a naming conference suggestion that helps you giving courses a job, relationship, obligations and states in a transparent approach.

Positively a strategy to save time when deciding class names.

  • Block: the guardian, the standalone entity that has a that means by itself (high stage abstraction of your part)
  • Aspect: part of the block, with out that means standalont by itself (a toddler merchandise)
  • Modifier: a flag, a variation, a state to a block or ingredient

Right here is an instance of BEM utilized to a button

<a category="button button--big">
    <span class="button__icon"></span>
Enter fullscreen mode

Exit fullscreen mode

.button {
    show: inline-flex;
    justify-content: middle;
    align-items: middle;
    border-radius: 6px;
    padding: 8px 12px;
.button__icon {
    margin-right: 6px;
    font-size: 0.5rem;
.button--big {
    padding: 12px 16px;
    font-size: 20px;
Enter fullscreen mode

Exit fullscreen mode

CSS Namespaces

What number of occasions have you ever checked out a chunk of HTML solely to surprise:

  • which courses do what
  • which courses are associated to one another
  • which courses are non-compulsory
  • which courses are recyclable
  • which courses are you able to delete, and so forth?

Loads of occasions, I guess.

A CSS Namespace will let you know precisely how a category behave in a extra international sense.

Once more, this methodolgy is supposed for use when deciding class names.

ere are the person namespaces and a short description.

Object: o-

A category identify that begins with “o-” is an Object, an summary structure implementation. Utilized in any variety of unrelated contexts: tread fastidiously.

Eg. o-grid, o-sidebar-left

Element: c-

A category identify that begins with “c-” is a Element: this can be a concrete, implementation-specific piece of UI.

Eg. c-hero, c-card

Utility: u-

A category identify that begins with “u-” is a Utility class. It has a very particular function and it may be reused and is not tied to any particular piece of UI.

Eg. u-color-primary, u-text-center

Theme: t-

A category identify that begins with “t-” provides a provides a theme to a view. Overrides default fashion as a result of presence of a theme.

Eg. t-light, t-saint-valentine

State: is- / has-

A category that begins with is- or has- signifies that this piece of UI is at present styled a sure approach due to a state or situation. Used in all places, not tighten to particular UI block

Eg. is-active, has-2-items

Javascript Hooks: js-

A category that begins with – js- signifies that this piece of the DOM has some JavaScript binds onto it.

Eg. js-carousel, js-accordion

ITCSS: Inverted Triangle CSS

It helps us to manage our CSS recordsdata to raised cope with CSS specifics/points/pitfalls like:

  • international namespace
  • cascade
  • selectors specificity.

On the finish, we break up CSS properties primarily based on their stage of specificity and significance.

Going from high to backside symbolizes a rise in specificity, and every subsection of the triangle could also be thought of a separate file or group of recordsdata.

My private implementation:

  • 1-settings: sass variables: font, colours, spacings
  • 2-tools: mixins and capabilities: bg-image(), abs-center()
  • 3-base: generic + components, normalize/reset + base html components fashion with out courses: physique, h1, desk (that is the primary CSS output)
  • 4-layout: (bear in mind objects?) summary layouts, unstyles patterns: grid, layout-sidebar, media
  • 5-components: fashion for a particular piece of UI: c-hero, c-footer
  • 6-modules: aggregation of modules: c-cards-list, c-cards-carousel
  • 7-trumps/utilities: utilities and helper courses with means to override something which fits earlier than, all CMS particular stuff like base overrides, views, particular web page fashion


The Article was Inspired from tech community site.
Contact us if this is inspired from your article and we will give you credit for it for serving the community.

This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 10k Tech related traffic daily !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?