PDA

View Full Version : css tags: to close or not to close


Madge
November 23rd, 2002, 06:57 PM
This my first post to any forum so please be gentle with me.
I am striving to create my first serious-purpose website and first with an external style-sheet. I tested against Explorer 6 and Navigator 7. Everything's o.k. except that Explorer added a line-space every time I closed a tag:
<h5>this is my heading</h5>
<h2>this is my body text</h2>
I could live with this if Navigator did the same. I accidentally left off a closing tag, and hey presto my problem was solved. I amended the whole site like so:
<h5>this is my heading
<h2>this is my body text
and uploaded it live. No problems!
All my content is enclosed within tables and within frames so I use rows and cells with transparent gifs to put space in where I want.
I thought leaving off closing tags was a floggable offence. What have I misunderstood? If some kind person could direct me to a suitable book or online tutorial I am prepared to educate myself.
Perhaps the frames/tables combo is the problem?

degsy
November 23rd, 2002, 07:12 PM
Tags should be closed. If you move on to XHTML then closing tags is required.

The reason for the space is because by default Headers & Paragraphs have margins to space them out.

Because you didn't close the tags, then your coding is incorrect and the browser tries to anticipate what the code should be.
This is why there is ALOT of bad coding on the net.



If you use CSS then you can control the margins yourself.
http://www.w3schools.com/css/css_margin.asp

Full CSS explanation
http://www.w3schools.com/css/default.asp



btw, you should only use Headers for erm.... Headers and you will probably only ever need <h1>, <h2> and <h3>.

You should use Paragraphs <p> for body text.

Madge
November 23rd, 2002, 08:41 PM
Many thanks Degsy for your prompt reply. So I will be flogged! You only confirm what I already understood to be the case, but you have directed me to the answer by pointing me to the margin property and that excellent site for my many future queries. I shall download my whole site tomorrow and will not upload another byte again until I am really thinking XHTML!

(Still a bit odd that Explorer and Navigator behaved differently on such a fundamental issue, but I don't care anymore!)

Thanks again!

Steven.Bentley
November 24th, 2002, 08:22 PM
Originally posted by Madge

(Still a bit odd that Explorer and Navigator behaved differently on such a fundamental issue, but I don't care anymore!)


I'm afraid that Explorer and Netscape both try to invalid code in different ways quite often :(

http://validator.w3.org is always a good idea :)

Madge
November 24th, 2002, 08:44 PM
Thanks Steven

I am reworking the whole site in an attempt to make it XHTML compatible. When done I will submit it to the validator. If I still have problems I may trouble you kind people again but hopefully not.

Odd, but although I have read books on CSS and XHTML and thought I understood them, it took Degsy's fairly generalised comments to make me suddenly see the wood from the trees.

It is encouraging to know there is someone else out there!

Thanks again

degsy
November 25th, 2002, 02:09 AM
Madge, I only started learning XHTML a few months back.

Most of my info is from
http://www.w3schools.com/xhtml/default.asp

Steven.Bentley
November 25th, 2002, 08:07 PM
I've only recently started with XHTML, I'm using the validator as a learning tool as I go rather than when I think I've finished :)