Forum Moderators: open

Message Too Old, No Replies

Why the trailing /

Is this a helpful, required element

         

roblaw

3:55 pm on Feb 3, 2005 (gmt 0)

10+ Year Member



Example:
<input type="text" name="email" value="your@email.com" />

I have been noticing more and more form elements, links to stylesheets, etc. with the trailing forward slash (/) as displayed above.

Am I missing something?
Is this a valuable thing to include?
Does it help a spider?
A browser to render faster?

Does this matter when linking to a URL in an href("http://www.anysite.com/" instead of just using "http://www.anysite.com"?

Pardon my ignorance on something that is probably very, very basic. This isn't something that we use and I want to be sure we aren't causing trouble for spiders or browsers by neglecting to use this.

Thanks for any responses.

encyclo

4:17 pm on Feb 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are two different things there: the first example of the trailing slash used in certain tags like the link element is to do with whether you are using XHTML rather than HTML. If you are using ordinary HTML rather than XHTML, then you should not have the trailing slash. Try putting your page through the HTML validator [validator.w3.org] which can help guide you.

For your second example, using the trailing slash in an URL, either in a link to the root page (example.com/) or to a directory (example.com/directory/) is highly recommended, as you are avoiding a server-side redirect to the correct address.

roblaw

4:30 pm on Feb 3, 2005 (gmt 0)

10+ Year Member



Thanks encyclo,

We do validate and don't have any issues there. However, it seemed odd to me that I was seeing this more and more at other sites and had no idea what it was there for.

My main concern was that it was in the form elements such as 'text'. I thought it might have something to do with the way that some of the lesser used browsers like the Mac browser or Firefox read the page.

If anyone has any additional input it is appreciated.

Thanks.

roblaw

tedster

5:58 pm on Feb 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm seeing lots of wrong use of <input />, <image /> etc tags in recent months. This is the Xhtml style of tag, but I see a lot of html DTD pages using it. It's not valid, just part of the "code soup" that passes for html on so many sites at the moment.

Some of it may come from using copy and paste for chunks of mark-up, and some of it from carelessness or sheer ignorance. Because the mark-up doesn't break in most browsers, I expect we'll see it more and more.

encyclo

6:34 pm on Feb 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In addition to tedster's correct assertion that such markup comes from copying samples from XHTML documents into HTML documents without the author realizing the difference, a lot of the trailing slashes are inserted by major CMSs, wikis and other publishing systems. For example, a standard phpBB install uses a template with an HTML 4.01 doctype, but the markup hardcoded in the system (thus not in the templates) is all using the XHTML notation. Unless you delve into the source code of the application (and in the process make upgrade management much harder) you're stuck with them. In my case, as I prefer my pages to validate, I had to convert my phpBB forum templates to XHTML 1.0 Transitional in order to fit with the hardcoded elements.

It's much the same in other systems: a certain amount of "future-proofing" has pushed (usually in error) the builders of such systems to use XHTML notation by default, even if their templates remain the invalid, tables-based, tag soup variety. Also, until a few months back, the W3 validator accepted XHTML notation within an HTML document, so many such systems "validated" solely because of the way that the validator handled the issue.

[edited by: encyclo at 6:40 pm (utc) on Feb. 3, 2005]

roblaw

6:34 pm on Feb 3, 2005 (gmt 0)

10+ Year Member



Thanks Tedster.

I really appreciate hearing from you on things like this. Your presentations at the LV PubCon made me rethink/rework a lot of my bulky code.

roblaw