r/neocities • • 13d ago

Help Class code in style sheet not working.

I'm trying to turn all of a class's background into blue, but when I put the code into my style sheet it wont work (the same code works perfectly fine in the style section on the main page). The stylesheet link isn't broken because the background is working perfectly fine. I'm VERY new to HTML coding so sorry if this is a really easy fix. I will answer any questions if needed

2 Upvotes

11 comments sorted by

1

u/Redmega 13d ago

Hmm I don’t see anything wrong with your code. Are you sure that’s the same css file being loaded? Maybe you put the background image in another css file too? Try adding this to that file and see if stuff gets outlined red:

```
* {
outline: 1px solid red !important;
}
```

1

u/That1DurpyZombie 13d ago

I have no fucking clue what I did, but I somehow fixed it. I removed the ending characters the code that adds the background to my page, and then rewrote it the EXACT SAME WAY AS BEFORE, AND SOME HOW IT WORKS????? I DON'T UNDERSTAND IT.... Thanks for the help lmao.

1

u/Redmega 13d ago

Weird, could have been a caching issue maybe? If you copy pasted it from somewhere maybe there was an invisible character that was causing it to fail? Unsure. Glad it’s working now!

0

u/blob-h https://blobh.site 12d ago

why are we using the entire neocities url and not just a path

1

u/That1DurpyZombie 12d ago

I was experimenting with what would and wouldn't work and forgot to change it. I tried just the directory but it wouldn't work.

-1

u/blob-h https://blobh.site 12d ago

using the path will not work if there's a / at the beginning. src="/images/a.png" is bad src="images/a.png" is good

7

u/Mevdik mevdik.net 12d ago

What? Starting a file path with a / is how you define said path as root relative, where / represents the root directory of the website's file system.

The only situation in which this won't work is if you are working locally without using a web server to serve the site, just opening your HTML files in the browser instead. This is because your browser will interpret / as the root of your computer's file system (on a UNIX-like OS at least) rather than the root of the website, so it won't find any resource linked as root relative. Running even the simplest local web server fixes this, which one should honestly be doing when working locally anyway.

Root relative paths are great because you always write them the same way no matter where the in the file structure the file you are editing is in. So you never have to write things like ../../assets/image.png when editing something that is a couple of levels deep, it's always /assets/image.png no matter where you are.

0

u/blob-h https://blobh.site 12d ago

I'm just saying what works and doesn't work for me. when i add the / the image doesn't work and when i remove it, it does work. both locally and on a server

3

u/Mevdik mevdik.net 12d ago

Are you sure that is the case? Because when I go to your website and edit any of the src for an img by adding a / at the beginning they still show up. Meanwhile if I add or remove anything else they stop displaying.

It would be very odd if this universal standardised thing that works for everyone does not work for you specifically.

0

u/blob-h https://blobh.site 12d ago

no idea idk im laying in bed rn

2

u/Mevdik mevdik.net 12d ago

Understandable honestly lol, have a nice nap or whatever.