Body background color on External CSS file doesn't change the background of the page for mobile, only for laptop, why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Body background color on External CSS file doesn't change the background of the page for mobile, only for laptop, why?

So, I'm confused, I recently decided to change the background from lightcyan to yellow, and when I uploaded the CSS file in the server it worked just fine on laptop, but on mobile it kept light cyan for some reason, I had to use the style element in head in order to make it work, what could create this error? I'm using a free server, could it be the server's fault? Maybe for some reason it did not update the CSS file for mobile, but why would it be fine on laptop then? The other html files I added were uploaded just fine.

13th Jul 2020, 9:08 PM
Karak10
Karak10 - avatar
3 Answers
+ 2
Try running the page on incognito mode , and definitely it's the problem of caching, well caching are done at various steps, If your website is live then at server side as well the caching is done automatically, if you are using cloudflare their as well static content are cached, and at the client side definitely the browser does the caching.. if the changes have been done and it works fine on laptop, then on your smartphone, please navigate to your phone settings and clear the cache of the browser app.
13th Jul 2020, 10:08 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
Laaunos no, the code is fine, if the code had problems then the page wouldn't be working fine on laptop. Its obvious that the CSS file hasn't updated, if the problem was something else, for example, if the CSS file wasn't linked correctly it wouldn't have kept the old background color and the paragraphs wouldn't be aligned to the center, it has something to do with cache I believe, thats what I found while searching in google, you have to force it refresh with the version, or there are other ways too. I still haven't tried this out tho to see if what I read is true.
13th Jul 2020, 9:42 PM
Karak10
Karak10 - avatar
0
I saw other people have had the same problem, and that I can write href="name.css?version=1" and increase that number whenever I want to update my CSS, so should I just do this for every singles HTML document I have?
13th Jul 2020, 9:16 PM
Karak10
Karak10 - avatar