skip to Main Content

I want to merge these two CSS. What are the possible ways to do this

.home .site-content .content-area{width: 100%;}
.archive.category .site-content .content-area{width: 100%;}

These two line of CSS should me merged in a single line.

2

Answers


  1. The vanilla CSS Selector would be:

    .home .site-content .content-area,
    .archive.category .site-content .content-area {
      width: 100%;
    }
    

    As soon as you use a CSS Preprocessor such as SASS or LESS you can nest. Alternatively, you have to wait a while until WHATWG releases the specifications for CSS nesting. In SASS or LESS you can use:

    .home,
    .archive.category {
      .site-content . content-area {
        width: 100%;
      }
    }
    

    If you want to display it in one line, you can ofc write it in one line for a minified version.

    Login or Signup to reply.
  2. Use :is().
    It’s pure css with MDN documentation

    :is(.home, .archive.category) .site-content .content-area {width: 100%;}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search