Hacker News new | past | comments | ask | show | jobs | submit login

nope. you've got a couple of options -

  .info {
   font-size: 8px;
  }
  
  .news {
   color: black;
  }
  
  <div class="info  news">asdf</div>
or maybe

  .info {
   font-size: 8px;
  }
  
  .news {
   color: black;
  }
  
  <div class="news"><p class="info">asdf</p></div>
or even

  .info, .news {
   font-size: 8px;
  }
  
  .news {
   color: black;
  }
  
  <div class="news">asdf</div>
but you've got to use LESS/SCSS for true 'extends' type functionality. vanilla CSS is more focused on inheritance.



Out of these, only the last one seems somewhat okish to me. But it would be annoying to add another selector everytime you add a class that uses the rule.

If that is all we have, then I will just stick to css variables:

    :root {
      --info-font-size: 8px;
    }

    .info {
      font-size: var(--info-font-size);
      color: grey;
    }

    .news {
      font-size: var(--info-font-size);
      color: black;
    }




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: