0

I want to make a simple grid in HTML/CSS and therefore I decided to name them "1/2", 1/4", "2/4" etc. but these classes arent valid in css. I know there is a workaround out there but after a 30 minutes research I thought here I could get my answer.

.1/2{
  width: 50%;
}

I specifically need a workaround that I didn't found anywhere in this forum or on another site. Dont suggest me a generel name convention for declaring my css classes pls, I know what's valid and whats not, but I need this workaround.

LUEH
  • 45
  • 9
  • 1
    Something like this? http://jsbin.com/resigopiji/1/edit?html,css,output But I'm sure the W3 Consortium will kill a kitten every time you use it. – Álvaro González Jun 19 '17 at 15:05
  • @ÁlvaroGonzález Oh nos, not the kittens!! Kidding aside though, that's a great workaround! – I haz kode Jun 19 '17 at 15:13
  • Tip: All capital nicks don't look very well on the first spot, I suggest to become simply "Lueh". – peterh Jun 19 '17 at 15:53
  • Can I just say that while, _technically_, escaping the classes in the stylesheet as `.\31\2f\32` is the correct solution, it is not nice on the eyes, not to mention it's a maintainer's nightmare. I would stick to words that don't need escaping, so that you will know that a class name of `topleft` always corresponds to a selector of `.topleft`. – Mr Lister Jun 19 '17 at 18:45
  • @MrLister Perhaps I didn't get it right but I couldn't manage to escape `/`. – Álvaro González Jun 20 '17 at 08:36
  • @ÁlvaroGonzález [Works for me](https://jsfiddle.net/MrLister/8ot44tgm/). – Mr Lister Jun 20 '17 at 09:05
  • @MrLister Oh, sorry, I totally overlooked you were using `\2f` to encode `/`. Certainly, that works. – Álvaro González Jun 20 '17 at 09:19
  • @ÁlvaroGonzález Thank you for your help! I just needed the solution you mentioned first and I was not remembering it by myself, I did a little change in your bin so you can see what I try to make with it :) http://jsbin.com/mojawepiga/1/edit?html,css,output – LUEH Jun 20 '17 at 13:15

0 Answers0