English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm making a website on a plain text editor and have the page named index.html and the stylesheet as style.css

When I change the css file to make a style, it doesn't have any effect. (I'm checking the page with Firefox and the files are on my Desktop)

Heres the code for the page:





Beginner's End- Stop being a beginner and Learn!


Test





Testo test lorum ipsum nimquod alid







Here's the code for the CSS:

div.mainbody {
padding-left: 11em;
}

div.mainnav {
position: absolute;
top: 2em
left: 1em;
width: 9em
}

How would I get this to work?

2007-12-08 11:42:27 · 5 answers · asked by Henry T 1 in Computers & Internet Programming & Design

It has now been changed to:






Beginner's End- Stop being a beginner and Learn!


Test






Testo test lorum ipsum nimquod alid







AND

.mainbody {
padding-left: 11em;
}

.mainnav {
position: absolute;
top: 2em
left: 1em;
width: 9em
}

But it still won't work. What gives?

2007-12-08 11:53:21 · update #1

5 answers

I would suggest a couple of things,

1) in your style.css file change your div's from .mainbody to #mainbody and .mainnav to #mainnav

2) in your website directory, where is the style.css in relation to this page that you have made? If it's in the same directory, then in the html page change

href="/style.css" to href="style.css"

3) you've missed one terminating ";" symbol in the css on the "top: 2em" line. And, as a good practice, you should also terminate the "width: 9em" line with a ";"

Here's what I rewrote and tested on my system. I added a default body style, just my preference.

=========
style.css - located in same directory as test.html
=========
body{
margin:0;
padding:0;
background-color: #ccc;
}

#mainbody {
padding-left: 11em;
}

#mainnav {
position: absolute;
top: 2em;
left: 1em;
width: 9em;
}


==========
test.html - no modifications needed here.
==========




Beginner's End- Stop being a beginner and Learn!


Test





Testo test lorum ipsum nimquod alid





=============

If you load the html page, then you can tell it's hitting the stylesheet because of the "ccc" background color.

2007-12-11 13:45:30 · answer #1 · answered by Kevin 7 · 5 1

Learn about selectors in css.

...


is select with

#mainbody {...}

(id's are only allowed once per page)

You can use a class, allowed multiple times on a page:

In our xhtml:
...

in the CSS:
.note {...}
or
div.note {...}

2007-12-08 11:50:25 · answer #2 · answered by anonymous 3 · 5 0

In your CSS, you forgot to add a semicolon to the "top" and "width" property values. i.e. is should be:

div.mainnav {
position: absolute;
top: 2em;
left: 1em;
width: 9em;
}

2007-12-08 13:28:44 · answer #3 · answered by A* 7 · 0 0

To open and edit your html pages you can use Kompozer. Download it for free here http://bit.ly/1rH1A9M
I have been using it for years
Cheers ;)

2014-07-27 03:56:20 · answer #4 · answered by Anonymous · 0 0



Now this is how the html/css tag is setup. it's no big deal, but you can download HTMLkit. That html editor will help you with your tags.

An external style sheet may be linked to an HTML document through HTML's LINK element:






The tag is placed in the document HEAD. The optional TYPE attribute is used to specify a media type--text/css for a Cascading Style Sheet--allowing browsers to ignore style sheet types that they do not support. Configuring the server to send text/css as the Content-type for CSS files is also a good idea.

2007-12-08 11:48:06 · answer #5 · answered by Johnny S 2 · 0 3

fedest.com, questions and answers