April 28, 201016 yr Hi Many times I have this problem. I have all my common CSS styling codes in a separate file, and all my website's files link to it by adding <link rel="stylesheet" type="text/css" href="webstyle.css"> in the head section. My styling contains my background color, font color, etc. So that's fine. All pages display as they should. However, when I need to make a specific page somewhat different, I don't know how I should add CSS. What I usually do is just add the same code I mentioned above in the head's section and then add my extra CSS in the page I want to modify. To add the CSS for example I might say <style type="text/css"> body { background-color:black; } </style> Sometimes this works but sometimes not. Specifically the example I gave here with the black bg color doesn't work. Why? I'm I doing it the right way? Also think I'm doing something wrong, as many times my CSS styles are confused, for example, a page may be reading CSS styles from another page, even if I didn't tell it to read CSS from there. Thanks in advance.
April 28, 201016 yr My advice would be stick to your styles on a separate file; you can always create a second file and refer to it as you did the first. The idea is then you can edit your css easily without touching the html. Saves you a lot of time and bother. If you have css in your html and separate it begins to confuse as to where problems may stem from . HTML dog has some great info to help you get up and running... starting here if you like : http://www.htmldog.com/guides/cssbeginner/applyingcss/ Hope this helps
April 28, 201016 yr Author Thanks. What you are saying is that I should avoid putting CSS styles in my HTML files, and just put all my CSS styles in one or more CSS files? I'll try it now, thanks it sounds more tidy anyway.
April 28, 201016 yr Yes that's what I'm saying. In some cases I believe inline (in HTML) styling is appropriate, but this is in relation to other languages and not in most html / css coded sites. It just makes for really hard work when you come to (and you will) edit and play around with code to get things to behave as they should in all browsers!
Create an account or sign in to comment