Tags for this article: html, meta elements, search engine, tutorial
Here we continue our section on Meta elements and the following topics more closely: using Meta elements for preventing your HTML file from being indexed by search engines, defining the file’s encryption, defining the script and style languages and ensuring files are loaded from their original address.
Allow or forbid your file from being searchable and indexed.
Most search engines take the following elements into consideration.
If you offer a HTML file online, but still want to prevent it from being reachable using public search engines, then you can note the necessary instructions for the search engine in the Meta elements. Of course, you can also signal to the search engine that you expressly wish for your site to be indexed and searchable.
An Example:
<head>
<meta name= “robots” content= “noindex”>
</head>
Explanation:
With <meta name= “robots” content= “noindex”> you forbid a search engine from transferring content from your HTML file to a search databank.
The following elements are also additionally possible.
<meta name= “robots” content= “index”>. With this you expressly allow the search engine to transfer content from your HTML file to its search databank.
<meta name= “robots” content= “nofollow”>. With this you forbid the search engine from visiting other files that you link to in your project. In order to forbid this as well, you could write <meta name= “robots” content= “noindex, nofollow”>.
<meta name= “robots” content= “all”>. With this you expressly allow the search engine to visit other files that you link to, and index them accordingly.
Take Note:
For those interested in the controlling of robots, we will dedicate a separate section to the topic later.
Elements for Encryption.
With the help of Meta elements, you can determine what encryption the HTML file uses. This piece of information is especially important for web browsers, because it tells the browser which encryption should be used to transfer the bytes into characters.
An Example:
<head>
<meta http-equiv= “content-type” content= “text/html; charset=ISO-8891-1”>
</head>
Explanation:
The element for the encryption is defined with http-equiv= “content-type”. This verifies that a designation is being made that normally is sent from the web server to the web browser in the HTTP header Content-Type. Then enter the MIME type for content, which is in the form text/html for HTML files. Then the information regarding the encryption follows, separated with a dash, in the formula of charset together with the unique encryption name. In the upper example we give the ISO-8859-1 encryption for West European languages. Encryption values are allowed as they are defined on the following web address: http://www.iana.org/assignments/character-sets.
Take Note:
You might ask why the element for encryption is actually charset. For historical reasons, in many technical standards, including HTTP, the term “Character Set” is used instead of “Encryption”.
Elements for the Default Languages for Scripts and Style Sheets
HTML offers the possibility to directly note formatting and script codes in single elements with the event handler and style attributes. Even if CSS is the usual style language and JavaScript is the usual script language, the HTML standard leaves it open which complementing languages can be noted in these attributes. So that a web browser knows exactly which script language you use, you can specify what languages you use within the HTML file.
An Example:
<head>
<meta http-equiv= “Content-Script-Type” content= “text/javascript”>
<meta http-equiv= “Content-Style-Type” content= “text/css”>
</head>
Explanation:
The elements for the default script language and default style language have a uniform construction. You introduce the information for the preferred script language with <meta http-equiv= “Content-Script-Type”, and the information for the preferred style language with <meta http-equiv= “Content-Style-Type”. With the content attribute you have to enter the MIME Type of the desired language. For example, text/css is for style sheets and text/javascript is for Javascript.
If the elements for the style language are missing and you still use the style attribute, then the browser must assume CSS is the style language. So specifically stating the style language is not usually necessary. The browser behaves differently with script languages and event handler attributes: a browser may strictly not accept Javascript, unless it has been instructed to. The default script language must be given, according to the HTML standard, as soon as you use event handler attributes.
Loading Files from Original Addresses
Any website that is frequently visited online is saved in between a so-called proxy server. That is then a so-called proxy cache. Browsers also save loaded internet websites on the user’s computer. This is termed a browser cache. In many instances the cache storage saves resources and time. There is one disadvantage; namely, the user can likely be shown information that’s no longer up to date, because new data exists on the original site in the meantime. With the help of Meta elements you can force the data not to be loaded from a cache, but instead from the original server. This element is recommended if you frequently change content in your HTML file and load it online.
An Example:
<head>
<meta http-equiv= “expires” content= “0”>
</head>
Explanation:
With <meta http-equiv= “expires” content= “0”>, you ensure the HTML file will always be loaded from the original address.
With content, instead of a 0, you could also enter a specific date or time. Doing so ensures the file will be always be directly loaded from the server after the entered time period. The date and time must be entered in the international format. For example, as content= “Sat, 5 May 2008 12:00:00 GMT”. Mon, Tue, Wed, Thu, Fri, Sat, and Sun are allowed as abbreviations for the day, while Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec are acceptable abbreviations for the months.
Instead of 0, you could also enter a number. This number then refers to the number of seconds, after which the browser loads a file in its cache from the original address. With content= “43200” you enter a value of 12 hours.