Expected RBRACE in CSS

The error “Expected RBRACE” generally occurred if the right brace “}” is missing from our CSS code. Sometimes when we style an element, we forget to close the right brace. As a result, we will get an error i.e. “expected rbrace at line no“.

What does expected rbrace mean?

Whenever we style an element, we need to select the style by query selector. The opening and closing brace “{}” is used to enclose the style property of that element like below.

Expected RBRACE in CSS
.selector{
	position: relative;
	font-family: sans-serif;
	font-size: 20px;
}

But what if we forgot to write the right brace “}” ? We can’t get the expected result as the rest of the code will not going to work. See the below example.

.selector{
	position: relative;
	font-family: sans-serif;
	font-size: 20px;

Also if we forget to write the left brace “{“, we will also get the “expected lbrace at line no” error.

How to fix “Expected RBRACE” error at the media query?

We can also get the error when using media-query in CSS. So when we write media-query, we have to also enclose all elements with their element style in opening and closing brace “{}”. We also get the above error if there is missing any closing and the opening brace.

@media (min-width: 576px) {
  .selector {
  	background-color:#f00;
  }

Summery

In CSS, it is a common practice to group element in group or nested group, we have to use brace. If one brace is missing it may be opening or closing, it will effect on next element’s group.

About Ashis Biswas

A web developer who has a love for creativity and enjoys experimenting with the various techniques in both web designing and web development. If you would like to be kept up to date with his post, you can follow him.

Leave a Comment