Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random characters in CSS class names

Tags:

html

dom

css

sass

I have noticed one thing. On some sites such as tray.io, asana, fb etc They have random characters in css class names when you inspect them for example:

<header class="Header_XSDsdksdXKkSDD">..</Header>

Why are these characters generated and how are they generated?

Thanks.

like image 317
Smihkk Avatar asked Oct 30 '22 22:10

Smihkk


1 Answers

These are probably hash string of a technology similar to CSS Modules.

The main idea is that you use a tool that reads the CSS files and makes unique classes for your different "views". Doing this separates the CSS files per HTML file / template / JSX or whatever your setup is.

If you follow the idea behind it, you can easily achieve more scalable setup of your code, because it allows you to use global and local class names. This means that you will not rely on the "cascading" feature of the CSS to propagate any styles.

like image 107
drinchev Avatar answered Nov 09 '22 15:11

drinchev