Style Sheet not recognising new lines...

User 2080012 Photo


Registered User
13 posts

Hi
I came across a weird problem the other day. Sorted it myself but the forum users may be interested...
I like to hand write my own style sheets. One page I was writing needed a larger font size so I added a new line at the top of the *.css external sheet. it came up as the default size Times Roman and no matter what I tried it absolutely would not take (Century Gothic 72pt). No other styles were affected. What was weird is that if I doubled up the offending line in the style sheet, suddenly the correct font and size appeared.
What had happened is that I had accidentally pasted a short piece of code from another page at the top of the sheet (nothing to do with styles) and this must have been corrupting the scanning of the codes. What was strange also is that was in a line of notation which should have been ignored - also a tasteful shade of pale grey so not so easy to spot.
Seems like corrupt codes like this only affect the next line underneath and not the whole style sheet
User 379556 Photo


Registered User
1,554 posts

That sort of information can indeed be useful.

I wonder whether perhaps it's to do with the final character of the corrupt code - perhaps not a standard line ending, causing the next line to be treated by browsers as part of the corrupt code.
Frank
User 187934 Photo


Senior Advisor
20,227 posts

I would open a support topic if you can replicate.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2923147 Photo


Registered User
1 post

I had a similar problem today and I was able to solve it by deleting my history and reloading the page. I hope this helps!

My theory is that the page is remembering an older version of the style sheet and using that instead of updating to the new one on load. If that is the case adding this line of code under your <head> tag before deleting your history may help as well.

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
User 122279 Photo


Senior Advisor
14,519 posts

I don't know if this applies, but you probably know that the letters 'CSS' stands for Cascading style sheet. The word Cascading is the important one here. Paul, who started this thread, said he was adding style rules at the top of his style sheet. Could it be that he had styled the same font differently further down? If so, the last styling 'wins'. It might have been better if his new styling had been inserted further down.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 3086477 Photo


Guest
22 posts

You are basically facing a caching issue where your browser doesn't feel like actually requesting the new version from the server and instead uses the one cached in the internal browser cache.

Simply using Developer tools to disable cache will work during development but if your workflow is based on putting stuff online frequently you will eventually face a situation where you are not anymore in control which version of your CSS code your visitors see (and you can't count on them using their Developer tools to disable caching).

In order to prevent stuff like this from happening you should use a technique called "cache busting" which essentially means you will be appending stuff to your resource URLs that will change every time your resource files change. Essentially your CSS URL transform from this

<link rel="stylesheet" href="style/css_2-play.css" type="text/css"/>
to something like this

Regards,
J Wick
User 2088758 Photo


Senior Advisor
3,101 posts

Great suggestion Jimmy!
Taking over the world one website at a time!

Steve Kolish
www.misterwebguy.com

YouTube Channel:
https://www.youtube.com/channel/UCL8qVv … ttneYaMSJA

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.