Jump to content

Body styling won't work from external file


Jay@TastefulTitles.com

Recommended Posts

My site opens a html window containing a long series of divs with text. It uses a separate css file, all of which works except for the body styling. If I put the same styling (via cut & paste) into the html for the window, it works fine. The html and the css files are in the same folder.

There's no reason I can't add those few lines of css to the html in the ~30 windows that use it, but I'm curious why it won't work the other way. Here's the code:

<style>
body {
	background-color:#600;
	background-image:url(../images/Curtain%20narrow.jpg); 
}
</style>

You can view the css file (including the body styling) here. As I said, everything else in the css file works correctly, so the file is obviously being loaded and read. Is there a secret about body styling I don't know?

Link to comment
Share on other sites

1. Okay. I didn't know that. I don't think I had any.

2. The body css has all the same parent tags as the others, but it's the only one that doesn't work. Is that true even in a css file?

I'm missing the point of your first response. There is no body styling from the separate css file. There is from the html file.

Edited by Jay@TastefulTitles.com
Link to comment
Share on other sites

2 hours ago, dsonesuk said:

Wait! Now there is.

Apparently removing the <style></style> tags from the css file allowed it to work. I don't know why the first declaration (body) was the only one hindered, but now it seems to work fine. A newbie mistake, I'm sure, but you might keep it in mind for the next one who asks.

Thanks for your input.

Link to comment
Share on other sites

The max-width does not have a unit specified, also a bigger security problem is I can see a list of your folders and files if i remove slides.css from link, a quick fix is to add a blank index.html file in each folder other than the root/parent folder as it already has one which is your home page.

Link to comment
Share on other sites

I thought I had fixed the missing px, but hadn't. Thanks for pointing it out.

I have not heard of the security problem before, nor the simple fix. Thanks! Would you be interested in explaining how that helps? What could some miscreant do with my folders list, and how does the empty index.html prevent that?

Edited by Jay@TastefulTitles.com
typo
Link to comment
Share on other sites

It prevents no good doers easy access to list of your files and possible vulnerabilities.

The server is set by default on going to any directory folder and finding index.* or default.* (htm, html, php, asp, aspx etc) files on opening them first, so if a file has these extensions and it has nothing in them, all they see is a blank page.

https://www.thesitewizard.com/apache/prevent-directory-listing-htaccess.shtml

 

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...