Hello is there a way to hide the css code for viewers when they go to the path after viewing the source code of the website? or when checking it with w3c validator? or restrict access somehow. thanks
You'll never be able to hide it completely unless you move into complicated server-side rendering. You can however make it harder for people to simply view it by creating a master stylesheet and using the @import rule, but that will cause problems on older browsers. Alternatively, you can look into encrypting your coding with various applications. I've heard HTML Guardian can do CSS, but I've had no experience using it but it might be what you're looking for: htmlguardian.org/help_main.html Good luck!
The short answer is, no you can't. Afterall, the browser needs access to the CSS code in order to render the page, so any tricks you might use to try and hide it simply won't work - and if they do, you'll be staring at raw, unformatted HTML code.
You can "hide" it from regular people by using the @import rule. However, more skilled users will still be able to read it. Afterall, user's browser must read the stylesheet in order to display the website correctly.