skip to Main Content

So, I am a beginenr and I wrote a set of styles like:

.heading-background .author-class .publish-time{
  border: 2px solid black;
}

In index.html I have 3 different heading elements with these different classes; heading-background, author-class and publish-time. I want a border on all of them so I was wondering how to select em all and write only a single line for all of em using different classes.

I tried the aboove code and it didnt work, no error but no result also

2

Answers


  1. .heading-background, .author-class, .publish-time {
      border: 2px solid black;
    }
    

    This is the format for using multiple selectors for single style. And in your code there is a mistake between your classes style is that you missed comma(,).

    I would like to suggest to use html/css extension in the vscode, it will help you to identify your mistakes and also it’s useful for beginners.

    Login or Signup to reply.
  2. To group CSS selectors in a style sheet, use commas (,) to separate multiple grouped selectors in the style. You can place any valid selector in a group, and all elements in the document that match all the grouped elements will have the same style based on that style property.

    .heading-background, .author-class, .publish-time {
      border: 2px solid black;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search