...

View Full Version : Is this header right? (meta tags)



njfail
01-20-2012, 01:19 AM
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.


<!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>

Excavator
01-20-2012, 01:34 AM
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.

Arbitrator
01-20-2012, 12:58 PM
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.


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.


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:

<!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>

felgall
01-20-2012, 08:33 PM
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.

njfail
01-26-2012, 02:57 AM
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:

<!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

<html lang="en-US">
So I assume it needs to be closed at the end of the file with

</html>
Is it ok to have this in a .php file?
The only php I actually have is

<?php include $_SERVER['DOCUMENT_ROOT'] . '/footer.php'; ?>
Which is the only php I know how to use :rolleyes:
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?

felgall
01-26-2012, 06:46 AM
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.

Arbitrator
01-26-2012, 07:47 AM
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.


You suggest

<html lang="en-US">
So I assume it needs to be closed at the end of the file with

</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.)


The only php I actually have is

<?php include $_SERVER['DOCUMENT_ROOT'] . '/footer.php'; ?>Make sure that the footer.php file does not include a </html> tag.


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++).

njfail
01-26-2012, 08:45 PM
Thanks arbitrator that was very helpful :)
I understand it a lot more now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum