Home > Web Front-end > HTML Tutorial > Detailed explanation of HTML web page header code examples_HTML/Xhtml_Web page production

Detailed explanation of HTML web page header code examples_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:39:23
Original
3804 people have browsed it

Knowledge point 1: Set the base URL of the web page in the header information

The essence of the base URL is to uniformly set the attributes of the hyperlink. The base URL tag is , which has two attributes, href and _target. href is used to set the path of the base URL, and _target is used to set the opening method of the hyperlink.

By adding the base URL, all relative website root addresses in the page can be converted into absolute addresses. When the browser browses the page, it appends the relative website and directory address to the back of the base URL path through the tag, thereby converting it into an absolute address. We first create a base.htm and write the HTML code as follows:


Copy code
The code is as follows:


< head>
Base URL setting
http://www .jb51.net" _target="_blank" />




Set the base URL through the above code. The address of any hyperlink in the Base.htm page will be preceded by "http://www.jb51.net", which is converted to an absolute address. Moreover, the hyperlinks on the page are opened in new windows.

Knowledge point 2: Meta information tag of header information

The meta information tag is the basic tag for header information. Professional web page codes have detailed settings for meta information. The meta information tag is , which is a single tag. The information provided by the Meta element is invisible to browsing users and is generally used to define the name, keywords, author, etc. of page information. In an HTML page, a meta tag contains a meta content, and there can be multiple meta elements in an HTML header page.

Meta tag attributes are divided into two types: page description attribute (name) and http title information (http-equiv).

name attribute

The name attribute is mainly used to describe the content of web pages and is used for search engine optimization, so it must be mastered. Correctly set the name attribute so that the search robots of search engines (such as Google, Baidu) can find and classify. Search engines will generally automatically find meta values ​​to classify web pages. The value of name is as follows:

<1>keywords. That is, keywords are used to describe the keywords and other information contained in the web page, thereby increasing the probability of being searched by search engines. The writing format is , and the value of the content attribute is the specific keyword set by the user. (Generally, multiple keywords can be set, separated by English half-width commas. Search engines limit the number of keywords, so the keyword content should be concise and concise)

<2>description. It means "description" in Chinese and is used to describe the main content, theme, etc. of a web page. Reasonable settings can also increase the probability of being searched by search engines. The format is . The content attribute value is the specific description of the page set by the user. It can accommodate up to 1024 characters, but the search engine only displays about the first half of the page. 175 characters.

<3>author. Author, used to set the name of the website author, often used by more professional websites. The format is

<4>generator. Generator, used to set the name of the website editing tool, is often used on more professional website pages. Format

<5>robots. Bots, used to limit how pages are searched. The search engine's search robot continuously retrieves information and builds its own database along the links on the web page (such as http and src links). This meta tag can limit some content from being detected by search engines and reduce the disclosure of some information. The writing format is . The value of this attribute contains 4 commands, namely index, noindex, follow, and nofollow. There are 4 combinations according to the arrangement and combination. The combination of Index and follow can also be called all, and noindex and nofollow can also be called none.

http-equiv attribute

The values ​​of the http-equiv attribute are as follows:

<1>content-type, content category, used to set the category and language character set of the page. Writing format , the value of the content attribute represents that the page is output in HTML code, and the character set is gb2312 (Simplified Chinese) , for international website development, in order to unify characters, it is recommended to use utf-8 for charset.

<2>refresh. Refresh is used to set how long the webpage refreshes itself, or automatically jumps to other pages within a period of time. The first writing format means interval Refresh once every 30 seconds. The second writing format is , which means the page will automatically jump to www after 30 seconds. .google.comwebsite

<3>expires, which means "expire" in Chinese, is used to set the page expiration time. Once the web page expires, the web page must be recalled on the server. The first writing format is , the content value represents the expiration time of the web page, and the GMT time format must be used. The second writing format is , indicating how many seconds it will expire.

<4>cache-control, cache control. Used to prohibit calling web pages in the cache, the writing format is , no-cache means caching is not allowed.

<5>set-cookie, set cookie, used to set how long the cookie on this page will expire. The writing format is tag pair in the header information. The sample code is as follows

Copy the code
The code is as follows:



CSS settings





<2>To add JavaScript, you only need to add the tag pair in the header information. The sample code is as follows:


Copy code
The code is as follows:


< head>
CSS settings

< ;script type="text/javascript">
JavaScript specific content





Knowledge point 4: Recommended common header information functions

<1> Page switching special effects. The writing format of one of the special effects is as follows:

Copy code
The code is as follows:


When the value of the http-equiv attribute is page-enter, it means that special effects are enabled when entering the page. When the value of the http-equiv attribute is page-exit, it means that special effects are enabled when exiting (leaving) the page.

The value of the Content attribute represents the type of special effect, which is also called a dynamic filter. There are many types of filters. For example, blendtrans is a very common one. The effect is fade in and fade out. The duration value indicates the duration of the effect (in seconds).

Another filter effect writing format is as follows:


Copy code
The code is as follows:


The dynamic filter revealTrans can also be used for page entry and exit effects. Duration represents the duration of the filter special effect (in seconds), and Transition is the filter type, indicating which special effect you want to use, and the value is 0~23.

<2>Forcing the page to be displayed as an independent page in the current window can prevent the webpage from being framed by other websites. The writing format is as follows:

Copy code
The code is as follows:


<3> Page icon settings, the writing format is as follows:

Copy the code
The code is as follows:


The value of the href attribute is the path to the ico icon file, here the relative root directory path is used

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template