Lazer
Lazer

Reputation: 94830

What is the difference between these two HTML meta tags?

First:

<meta http-equiv="refresh" content="0" url="http://www.google.com"/>

Second:

<meta http-equiv="refresh" content="0;URL=http://www.google.com"/>

The first one seems more sane, but does not work, while the second one works, but seems ill formed.

Upvotes: 0

Views: 214

Answers (3)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201568

The main difference is, as you say, that the latter (often) works, the former does not. The former does not comply with any HTML specification or draft either; there is no attribute named url in HTML. (Attributes that take URL values have names like href and scr, by the way.)

The latter is in principle more vague in HTML specs and drafts. HTML 4.01 mentions the construct indirectly, without giving the exact form: “Some user agents support the use of META to refresh the current page after a specified number of seconds, with the option of replacing it by a different URI. Authors should not use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects.”

But HTML5 CR more realistically describes the construct and its function in detail and declares it as conforming.

From the HTML perspective, the value of the content attribute is just a string, which may be subject to rules defined in other specifications. In this case, the odd format imitates an HTTP header, which was originally introduced by Netscape, later widely supported by browsers though never standardized in HTTP specifications.

Upvotes: 0

nl-x
nl-x

Reputation: 11832

According to W3 schools (yeah, I know. Not the best source according to some know-it-alls, around here) the Meta tag only has 5 supported attributes:

  • charset (html5 only) : Specifies the character encoding for the HTML document
  • content : Gives the value associated with the http-equiv or name attribute
  • http-equiv : Provides an HTTP header for the information/value of the content attribute
  • name : Specifies a name for the metadata
  • scheme (not in html5) : Specifies a scheme to be used to interpret the value of the content attribute

Upvotes: 0

Zeta
Zeta

Reputation: 105886

A meta tag with http-equiv is actually a way to put the *equiv*alent of a HTTP response header into a HTML page. A header in HTTP consists of field name and content, thus the second is in this case correct.

Upvotes: 2

Related Questions