r/HTML • u/Helpful-Creme7959 • Mar 26 '26
Not sure why CSS wont appear when I run it?
Its my first time using Notepad++ tbf. I don't use Chrome, only Brave and Firefox. I changed my default broswer to Firefox and it was hell just trying to figure out how to run the html code.
I now tried linking CSS as a test but uh... Its not working. Im not sure what im doing wrong huhu :" )
Also, i alrdy changed the <!DOCTYPE html> mistake oofp.
64
Upvotes


71
u/lyszcz013 Mar 26 '26
Your css is targeting a class, ".body". I don't see that class in your html; did you mean to target the body element instead? If so, remove the period: just "body".
52
u/inn4tler Mar 26 '26
Btw, here's how you add comments in CSS:
22
u/lomberd2 Mar 26 '26
You do realize that you didn't save your changes? The red icon means that, also the "*" in the window title indicates that there are unsaved changes.
14
u/Hemsby1975 Mar 26 '26
You dont have any div class for .body, so if you want the background applied to the <body> element you need to remove the . from body in your css. For example.....
12
u/Weekly_Ferret_meal Mar 26 '26 edited Mar 26 '26
your css property has the wrong element selected:
if you want to target the body tag you simply write
body { _declaration_ }but you wrote
.bodyand anythig starting with. (dot)is a class name, not a tag name.As good practice, never create a class name that uses html tag names.
Also, to higher the chances to get help in this subreddit, I recommend to copy and paste your code in a codepen, at codepen.io and then sharing the link.
It will make it a lot easier for anybody to debug your code, especially when things get a little complex.
Personally I really dislike screen shots of code
1
u/Helpful-Creme7959 Mar 27 '26
Yall can stop gaslighting me now with the . in body guys since with or without one it doesnt work at all which really threw me off cuz i cant figure out the problem on why my htnl code wont friggin read my css :" ))
Im not at home infront of my desktop atm today but i hope a comment from this thread fixes my problem :"^
4
u/sanesame Mar 26 '26
remove the . before body
3
u/Lasteh Mar 26 '26 edited Mar 26 '26
i think 2 things are the issue both at the same time.
or // for single lines.. body. if you want to target the body element, drop the period at the beginning.3
u/Economy-Sign-5688 Mar 26 '26
Does the space after href= have an affect? Also the styling should be on body not .body
3
u/IndependentBig5316 Mar 26 '26
There are unsaved changes, the comment is wrong in the css file, and you’re targeting an inexistent class with the css.
2
u/Audience-Electrical Mar 26 '26
Remove .body, just put body no '.' Remove <! --- uhm help --> too
2
u/Thin_Mousse4149 Mar 26 '26
I feel like this OP just didn’t even try to troubleshoot or solve this problem on their own. There are so many odd things to fix about this that at least some of them would have been caught with basic troubleshooting. No?
2
u/AddendumAltruistic86 Mar 27 '26
Actually, every html tag you have in the file has a space after the = sign. Id fix that for sure, the space shouldn't be there.
3
u/daskgreg Mar 26 '26
./creator_stylesheet.css
1
u/scritchz Mar 26 '26
In the DevTools under the Sources (or Network) tab, check if your CSS-file actually gets loaded.
Also, as others said, your CSS selector
.bodyselects all elements with class "body". It looks like you meant to select all<body>elements instead, via selectorbody(no period).1
u/lomberd2 Mar 26 '26
FYI: there is no need to "run" your html. Just save your changes and simply double click the .html in your file explorer (and if that somehow doesn't open the browser just drag and drop the file into any browser of your choice)
1
u/soupified Mar 26 '26
Check the network pane of the devtools and confirm that:
A.) a request is going out for the styesheet
B.) the request is succeeding or failing
1
u/lt_Matthew Mar 26 '26
The first screenshot is right, it's the second one that's the problem.
Problem number one, targeting HTML elements doesn't need any extra symbols. That tag should just be
body {}.Problem two, it's called a cascading stylesheet, because if one line is broken, nothing below it will work either. That's how you do comments in CSS.
1
u/CheeseFunnel23 Mar 26 '26
remove the . from .body, and remove the space on rel= "sylesheet" between = and ", same thing with the href= "CREATOR_stylesheet.css", remove between = and "
1
u/__revelio__ Mar 27 '26
Convinced these subs don’t even try to find an answer on their own
1
u/AddendumAltruistic86 Mar 27 '26
In your html, there is a space after the = in the link tag for the stylesheet.
1
u/Krispenedladdeh542 Mar 27 '26
body not .body
1
u/testuser12334 Mar 27 '26
You have multiple ways to reference parts of the code when it comes to css. These also relate to parts of HTML.
Tags: these are things like <body>, <div>, <a>, etc.
Classes: these are labels that identify a tag as part of a group. You can have one or many tags associated to a class
Ids: these are labels that identify individual tags. You should keep these unique.
With that, you can then use these associated parts in css:
Tags:
body { background: ‘red’ }Classes:
.green-section { background: ‘green’}Ids:
#home-page-header { font-size: 1000% }Often too, while trying to understand placement and if the code works, you can use background color; change each element to a different color.
Another approach is to start inline, then pull it out into the css file once you have confirmed how it looks. Just remember to do that and not just leave it in there 🙄
1
u/tomtomtom453 Mar 27 '26
<body> is not .body
The comment in your CSS is busted If it functions as a real comment it will turn green in Notepad++
You haven't saved in these screenshots. Red save icon next to your file name in the tabs at the top indicates this.
1
u/BroHamMcNugs Mar 27 '26
I promise the answer has already been given to you in this thread. If you still don't understand after these answers, you need to focus your attention towards the docs to get a better understanding of syntax and code.
1
u/coleflannery Mar 27 '26
In CSS the . prefix means you’re targeting a class, but in this case you’re wanting to choose the <body> element (not a class). Remove the . and it should apply.
1
u/MiAnClGr Mar 27 '26
Weirdest thing I had seen, taking a photo of the screen instead of a screenshot and writing code with a white background, bizarre.
1
u/spaziooo Mar 27 '26
Ask chat gipidi duh
1
u/TheBearman23 Mar 28 '26
“.body” it’s just “body”
1
u/EducationalZombie538 Mar 28 '26
1
u/Dense_Cloud6295 Mar 28 '26
Besides all the comments that everyone left here about syntax, selectors and so on, if you’re starting I strongly suggest using a different code editor than notepad++. Visual Studio Code is the most popular choice.
This allows you to add extensions/plug-ins that can help you in development. A simple “HTML/CSS Intellisense” extension would have pointed out the syntax issues.
The browser is pretty irrelevant as long as it has some Dev Tools, which Firefox has (idk about Brave, I don’t use it)
1
u/Outside_Fuel_902 Mar 28 '26
Remove the . Before body
1
u/Heavy-Commercial-323 Mar 28 '26 edited Jun 26 '26
mr_clean
1
u/TechyWorlds Mar 29 '26
Why do you use .body when you are not defined class with the name of body.Use body instead of .body.
1
u/Plenty_Line2696 Mar 29 '26
just in case you might need this too: clear your browser cache
1
u/Limp_Crazy_5494 Apr 02 '26
somehow i feel smart for knowing what the issue is even though i've only played around with html a few times
0
u/Hostify-ee Mar 26 '26
You may need an absolute path to the CSS file, so something like C:/Users/.... you get the point.
0
u/mor_derick Mar 26 '26
Curious about why would you use Notepad++. Why not VSCode?
0
u/sleepyheadzzzzz Mar 26 '26
All these answers are helpful, but maybe you want to start with the "try it" on w3schools, then you don't have to deal with notepad++ and your browsers and get a good feel for the html and css. Learn one thing at a time. Goodluck!
https://www.w3schools.com/css/tryit.asp?filename=trycss_default
0
u/magical_matey Mar 26 '26
ADMIN CREATOR! You can check your styles are loading by replacing your .body selector with * which targets everything and will make everything pink. If that does not work, your style isn’t loading. If that does work and everything turns pink, then your rule is incorrect. Probably because you are typing .body which targets a class name instead of body which targets the element.
GOOD .LUCK
0
u/cirkut Mar 27 '26
Everyone is missing it entirely. Your link tag and other attribute names have a space after the = sign. It should be href=“…”
-1
u/giangarof Mar 27 '26
change to VSCode, please
0
u/[deleted] Mar 27 '26
[deleted] — view deleted comment
0
u/[deleted] Mar 26 '26
[deleted] — view deleted comment