html line ". {" is marked as an error in Eclipse when the html file is opened

Viewed 58

I have updated my Eclipse to 2021-03 with jdk1.8 and Tomcat 9. Now when I open a html the following css has an error on ". {" - identifier expected. When I close the file the error marker goes away.

 body {
        padding-top: 40px;
        padding-bottom: 40px;
        background-color: #f5f5f5;
      }
      . {
        max-width: 370px;
        padding: 1px 1px 1px;
        background-color: #fff;
        border: 1px solid #e5e5e5;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
      }
1 Answers

It's expecting a classname after . If your purpose is to apply css to entire document then use

*{
        max-width: 370px;
        padding: 1px 1px 1px;
        background-color: #fff;
        border: 1px solid #e5e5e5;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
      }

. is used for classes in CSS, hence it expects the . to be followed by a classname. For more info visit MDN for more info MDN CSS Selectors

Also for your convenience below is a screenshot of real-time log from vscode Real-time VSCode log

As you can see it says identifier expected, this means that a classname is a must after . selector and when you do something like .class_name{} you will see that the error is gone

Related