Jump to content

css


davidatk100

Recommended Posts

I'm pretty new to web page design but even when I asked a couple of my friends who are significanly more experienced, then couldn't really give me any answers.I've got index.html and master.css and they're both working fine except that the color that i've set in index.html doesn't work in firefox. I've had a look in explorer and it's fine there and one of my friends had a look on his computer useng firefox (linx) and he said it worked. It also works in the prievew then the file is highlighted but not yet opened.----------------------------------------------------------This is index.html:<html><head><link rel="stylesheet" type="text/css" href="master.css" /><title>Ben Mckinnon</title></head><body text="#ffffff" bgcolor="#000000"><img src="tabs/background.jpg" width="100%"><br><br><br><br><br><br><br><br>adhgkjasdhgjkh</body></html>------------------------------------------------------And this is master.css:body {background: url('tabs/background.jpg');background-position: top;background-width: 100%;background-repeat: no-repeat;margin:0}-----------------------------------------------the color of the background works fine and if I take out the 3rd line from index.html:<link rel="stylesheet" type="text/css" href="master.css" /> ...the background color works fineEdit: I'm aware of different ways I can organise the files eg. having an internal ccs instead of external etc. but I like it this way and if I can, I'd like to keep it this way.Appreciate any help.

Link to comment
Share on other sites

Generally developers will say always combine the body and html attributes into one css tag, like:body, html{ la dee daaaa}Anyways, try this:

body,html {background: #000 url('tabs/background.jpg') no-repeat;margin:0px;padding: 0px;}

and take out the bgcolor and text bits in the <body> tag. I think the problem with the background colour was the conflicting CSS declaration of it:

background: url('tabs/background.jpg');

the background: thingy also accepts a colour as it, using background-image: might solve it too. Thats why removing the link to the stylesheet called upon bgcolor in the body tag.Also remember for valid XHTML tags without a closing tag (such as <html></html>) should be closed with a slash. Image tags and line breaks:

<!-- Image tag XHTML valid --><img src="lala.jpg" /><!-- Line Break XHTML valid --><br />

good luck :)

Link to comment
Share on other sites

Generally developers will say always combine the body and html attributes into one css tag, like:body, html{ la dee daaaa}

Bad idea. If you switch to application/xhtml+xml media type, your background will be used both on the viewport and on the body which will become just a normal rectangle (like a div) around your page content. Only html should be used.
Link to comment
Share on other sites

I can't seem to set a backgrount picture in an external css, while setting the background color in the html (either by html tags or internal ccs). Is it possible?I want to do it this way because I want the picture to stay the same between pages but have the color change. Is geting rid of the external css and putting it all in the html file the only way?

Link to comment
Share on other sites

Put it all in the CSS. I just looked again and I believe it didn't work for you because you used the background property instead of background-image. However by using only CSS, you should be able to declare all background properties with just "background".EDIT: also, there is no "background-width".

Edited by F-Man
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...