Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-20-2012, 12:19 AM   PM User | #1
njfail
Regular Coder

 
Join Date: Aug 2010
Posts: 125
Thanks: 2
Thanked 0 Times in 0 Posts
njfail is an unknown quantity at this point
Is this header right? (meta tags)

I'm not entirely sure what the differences between charsets and traditional, strict, etc.
I just kind of copied things from tutorials. Is this info right? Its a .php file.
What does the copyright meta tag do?

Also, should I leave the description/title the same for content pages and contact/about us/privacy policy pages?
Or should each have its own description? Does it make a difference as far as search engines are concerned?

Thanks for the help.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="EN-US">
<meta name="Copyright" content="&copy; 2012 ERBoH.com">
<meta name="Description" content="Discussion forum, news, fan activities, contests, and hints to who will be in the next ERB!"/>
<meta name="keywords" content="Epic Rap Battles of History, nicepeter, epiclloyd, epic rap battle" />
<title>Epic Rap Battles of History Fansite</title>
<link href="/style.css" rel="stylesheet" type="text/css" />
</head>
njfail is offline   Reply With Quote
Old 01-20-2012, 12:34 AM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello njfail,
A good place to start with questions like this is the validator. See the links about validation in my signature line.

Most of those meta tags are hardly necessary though you do need a character declaration. I also think any new website should have strict DocType, not a transitional.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 01-20-2012, 11:58 AM   PM User | #3
Arbitrator
Senior Coder

 
Arbitrator's Avatar
 
Join Date: Mar 2006
Location: Splendora, Texas, United States of America
Posts: 2,900
Thanks: 5
Thanked 188 Times in 185 Posts
Arbitrator is on a distinguished road
Quote:
Originally Posted by njfail View Post
I'm not entirely sure what the differences between charsets and traditional, strict, etc.
Just use <!doctype html> for the document type declaration to declare your document as HTML. It's easy to remember compared to the old declarations

For the character encoding ("charset"), you should save your documents as UTF-8 in your document editor (there should be an option when you use the "Save As" command), and then label them as such. This is the preferred character encoding.

content-language meta elements are disallowed in HTML. Use the lang attribute on the html element to declare the document's language.

Quote:
Originally Posted by njfail View Post
What does the copyright meta tag do?
It doesn't do anything. There is not such a thing defined in the specification either. Put the information in a comment declaration if it really needs to be there.

Quote:
Originally Posted by njfail View Post
Also, should I leave the description/title the same for content pages and contact/about us/privacy policy pages?
Or should each have its own description? Does it make a difference as far as search engines are concerned?
The title and description meta elements should reflect their respective page. Google uses both of these in its search results.

The keywords meta element is still valid in HTML, but it is mostly useless since search engines don't use them due to author abuse.

There's also no need to declare the MIME type of your link element since the default type is text/css (though it doesn't hurt).

Example revised code:
Code:
<!doctype html>
<html lang="en-US">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Epic Rap Battles of History Fansite</title>
		<!-- Copyright © 2012 ERBoH.com -->
		<meta name="description" content="Discussion forum, news, fan activities, contests, and hints to who will be in the next ERB!">
		<meta name="keywords" content="Epic Rap Battles of History, nicepeter, epiclloyd, epic rap battle">
		<link rel="stylesheet" href="/style.css">
	</head>
__________________
Please for the love of god stop making IE. You current "browser"s cause me to cry every day. —Phil *
Arbitrator is offline   Reply With Quote
Old 01-20-2012, 07:33 PM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,456
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
The HTML 4 strict doctype indicates that you are using HTML 4 and do not have any old HTML 3.2 tags in your page.

The HTML 4 transitional doctype indicates that you still haven't finished getting rid of the tags that were allowed in HTML 3.2 but which were removed in HTML 4 in 1997 because there are better alternative ways to do those things in HTML 4. (Note that while HTML 4 became a standard in 1997, it wasn't fully supported by all browsers until about 2005 and so sites that were created before 2005 had to use transitional - only hobbyists have continued to create new transitional sites since then).

Specifying a doctype without including the version of HTML simply indicates that the version is HTML 2 or greater (since HTML 1 wasn't defined using SGML and so doesn't use an SGML doctype to identify the standard SGML definition of the language).

Any meta http-equiv would be better done server side before sending the page rather than including it in the HTML and hoping that the browser can update the specified setting after it has already started loading the page.

Unless you have code of your own that reads the meta keywords tag you may as well omit that one as the search engines no longer use it at all.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/

Last edited by felgall; 01-20-2012 at 07:37 PM..
felgall is offline   Reply With Quote
Old 01-26-2012, 01:57 AM   PM User | #5
njfail
Regular Coder

 
Join Date: Aug 2010
Posts: 125
Thanks: 2
Thanked 0 Times in 0 Posts
njfail is an unknown quantity at this point
Quote:
Originally Posted by Arbitrator View Post
Just use <!doctype html> for the document type declaration to declare your document as HTML. It's easy to remember compared to the old declarations

For the character encoding ("charset"), you should save your documents as UTF-8 in your document editor (there should be an option when you use the "Save As" command), and then label them as such. This is the preferred character encoding.

content-language meta elements are disallowed in HTML. Use the lang attribute on the html element to declare the document's language.

It doesn't do anything. There is not such a thing defined in the specification either. Put the information in a comment declaration if it really needs to be there.

The title and description meta elements should reflect their respective page. Google uses both of these in its search results.

The keywords meta element is still valid in HTML, but it is mostly useless since search engines don't use them due to author abuse.

There's also no need to declare the MIME type of your link element since the default type is text/css (though it doesn't hurt).

Example revised code:
Code:
<!doctype html>
<html lang="en-US">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Epic Rap Battles of History Fansite</title>
		<!-- Copyright © 2012 ERBoH.com -->
		<meta name="description" content="Discussion forum, news, fan activities, contests, and hints to who will be in the next ERB!">
		<meta name="keywords" content="Epic Rap Battles of History, nicepeter, epiclloyd, epic rap battle">
		<link rel="stylesheet" href="/style.css">
	</head>
I was told before that if its a .php file, then it shouldn't have html tags.
You suggest
Code:
<html lang="en-US">
So I assume it needs to be closed at the end of the file with
Code:
</html>
Is it ok to have this in a .php file?
The only php I actually have is
Code:
<?php include $_SERVER['DOCUMENT_ROOT'] . '/footer.php'; ?>
Which is the only php I know how to use
I only use it for the footer, since that stays the same no matter what. The meta tags (description) changes for each page so I don't use this php for that. I only have a few pages so its not a big deal. Do pages load faster if I put them in a .php file and link to them like above?
njfail is offline   Reply With Quote
Old 01-26-2012, 05:46 AM   PM User | #6
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,456
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
When using PHP it is what the final HTML that is delivered to the browser that is what matters when it comes to dealing with the HTML. How the HTML is generated inside the PHP doesn't matter to the browser as the browser only sees the final HTML.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 01-26-2012, 06:47 AM   PM User | #7
Arbitrator
Senior Coder

 
Arbitrator's Avatar
 
Join Date: Mar 2006
Location: Splendora, Texas, United States of America
Posts: 2,900
Thanks: 5
Thanked 188 Times in 185 Posts
Arbitrator is on a distinguished road
Quote:
Originally Posted by njfail View Post
I was told before that if its a .php file, then it shouldn't have html tags.
I don't see why that would be the case.

Quote:
Originally Posted by njfail View Post
You suggest
Code:
<html lang="en-US">
So I assume it needs to be closed at the end of the file with
Code:
</html>
Is it ok to have this in a .php file?
That should be fine unless you're already outputting the relevant tag somewhere else (in which case, you would have duplicate tags).

(The html element's tags are not strictly required; missing tags will be generated automatically for that element. However, it's good practice to use the tags; invisible element boundaries (i.e., tags) make for confusing code.)

Quote:
Originally Posted by njfail View Post
The only php I actually have is
Code:
<?php include $_SERVER['DOCUMENT_ROOT'] . '/footer.php'; ?>
Make sure that the footer.php file does not include a </html> tag.

Quote:
Originally Posted by njfail View Post
Do pages load faster if I put them in a .php file and link to them like above?
I'd guess that pages will load slower because your server must combine files before it responds to to the user's original file request. I'd expect any server-side processing action to slow down your pages.

Of course, putting the footer in its own file will probably save you editing time, so you'll have to weigh the benefits. If you really only have a few pages, you might want to avoid server-side includes; you can update all footers (in multiple files) at once by using a find-and-replace-in-files operation if you use an HTML editor that supports it (like Notepad++).
__________________
Please for the love of god stop making IE. You current "browser"s cause me to cry every day. —Phil *
Arbitrator is offline   Reply With Quote
Old 01-26-2012, 07:45 PM   PM User | #8
njfail
Regular Coder

 
Join Date: Aug 2010
Posts: 125
Thanks: 2
Thanked 0 Times in 0 Posts
njfail is an unknown quantity at this point
Thanks arbitrator that was very helpful
I understand it a lot more now.
njfail is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 PM.


Advertisement
Log in to turn off these ads.