Search code examples
cssnotepad++adobe-bracketsnul

How To Recover CSS Rules From A Corrupted CSS File


My .css file was working fine but today I noticed the website is not acting based on CSS rules so I tried to inspect the rues on browser and surprisingly I noticed the CSS file is empty! I tried to open the style.css file in Notepad++ and this is how it looks like

enter image description here

I also tried to open the file in Bracket editor which I got this message

enter image description here

Can you please let me know if there is a way to fix this issue and retrieve the CSS rules from these NULs?


Solution

  • If your file is indeed corrupted, and you have site backups as part of your hosting plan, restore your website to a point where your file worked. (Many web hosts that offer backups will store 30 days' worth, depending on your hosting plan.)

    If you don't have such a hosting plan, go to Wayback Machine and search for your URL. Pick a snapshot date when your site was working. Look in your source code and find a link to Wayback's cached version of your CSS file. Copy your CSS from there.

    Alternatively, try searching for your website in Google. Unless you have noarchive tags on your site, there should be a link right in your search results to access a cached version of your site. If Google last crawled your site before your file got corrupted, you should be able to access your cached CSS file through the source code (or a link in Dev Tools).

    Finally, check out this thread:

    https://groups.google.com/forum/#!topic/brackets-dev/4hEn8qs9MKs

    You may be able to open the file in a third code editor and save it as UTF-8.