Jump to content

Just wondering something about "required" HTML stuff


membot

Recommended Posts

I've never used html/head/body tags in pages, yet w3schools says it's "required". What does that mean exactly? It obviously still works without them. Also, what's the point of using <br /> instead of <br>? Or <img src="" /> and <img src="">? Is it really more "correct" to use the extra slashes? And why, exactly, if it all works the same?

Link to comment
Share on other sites

It obviously still works without them.

 

It might work in some browsers but could have adverse effects in others, the idea is to get your markup to validate to a specific document type.

 

what's the point of using <br /> instead of <br>? Or <img src="" /> and <img src="">? Is it really more "correct" to use the extra slashes?

 

The closing braces are required if you have chosen to use XHTML as your document type. Most people shouldn't be using XHTML as most servers still send XHTML documents with a mime type of text/html. So no, use a HTML doctype and you don't need the closing slashes.

Link to comment
Share on other sites

The point of it all is to create a site that will be cross-browser compatible, as well as search engine friendly. Without a proper doctype, and the required tags, browsers have to make guesses about how a page should look. They will still create something, but each browser will guess in its own way, and fixing these issues is near impossible.

 

On top of this, without a proper document structure, search engines also have to make guesses as to what the document is. Often they will guess wrong, and as such, your page will not rank as high on their indexes as an equivalent page that is properly structured.

 

So if you are creating a site and don't care if it looks properly in any browser other than the one you developed it on, and don't care about the search engines, then you don't need these things. And there are many amateur sites out there that don't use them. But anyone doing it professionally will properly use the tags and make their sites cross-browser friendly. So it really just depends on what your priorities are in making your site. If it's a personal site, then it probably doesn't matter. If it's a business site, it probably does.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.