I am getting CSS SyntaxError, unexpected token {. But I can not see error
Asked Answered
S

2

10

In Wordpress on localhost Laragon I am trying to get CSS. It throws 403 error: enter image description here

enter image description here

I can't find error, what could it be?

Starvation answered 25/9, 2018 at 12:52 Comment(9)
Your CSS file is being processed as JavaScript. For obvious reasons, this won't work.Inelegant
try to remove the comment of the CSS fileSmokestack
check your css i think some of the css class is not closed ( } ).Pabulum
@geeksamu Why? /* comments */ are a perfectly valid part of CSS and should even be considered mandatory.Inelegant
@VikasJadhav I don't even know where to start with that one. The error is occurring before any possible place where a } would "fix" it.Inelegant
@NiettheDarkAbsol validate your css here csslint.net it will show you all the erros in your css.Pabulum
How is the CSS being linked in the HTML? It appears that it is being linked as JavaScript.Antiquarian
@VikasJadhav Yup. No errors in the code shown, especially not at body {. Funny that.Inelegant
show us how you are include the CSS fileBevan
T
14

You're probably using wp_enqueue_script() Wordpress function to include your stylesheet file, and that's what could cause the error because it will call the css file using script tag.

Try using wp_enqueue_style() function instead.

Trichoid answered 25/9, 2018 at 14:19 Comment(2)
Yes, that's it. Thank you :)Starvation
thanks ! I had the same error while adding bundles in MVC with scriptBundle instead of StyleBundle.Conductor
I
22

You css file is being processed as a javascript file. Are you sure the file is being included as a css file as in

 <link href="style.css" rel="stylesheet">

and not

<script src="style.css"></script>

Also if you are adding this in code make sure you are using the wp_enqueue_style() method

Innumerable answered 25/9, 2018 at 14:14 Comment(0)
T
14

You're probably using wp_enqueue_script() Wordpress function to include your stylesheet file, and that's what could cause the error because it will call the css file using script tag.

Try using wp_enqueue_style() function instead.

Trichoid answered 25/9, 2018 at 14:19 Comment(2)
Yes, that's it. Thank you :)Starvation
thanks ! I had the same error while adding bundles in MVC with scriptBundle instead of StyleBundle.Conductor

© 2022 - 2024 — McMap. All rights reserved.