This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Hierdie gesprek is in die argief. Vra asseblief 'n nuwe vraag as jy hulp nodig het.

What standard, if any, specifies how a browser responds to a content type specified by the "type" attribute of the anchor tag?

more options

I had hoped that the following HTML code would FORCE the browser responding to the anchor by treating the content as plain text: <a href="file:path" type="text/plain">anchor text</a>. Likewise: <a href="file:path" type="text/html">...</a> should FORCE the browser to treat the responding reference as HTML code. Firefox does this (good for you!). However, Google Chrome and Internet Explorer seem to ignore the given content type and treat the response according to however they feel (which seems to be according to the file extension). I was hoping to find a standard that describes how a browser handles a source-specified content type. I have looked at W3C's html and http standards and have yet to find any applicable description or requirement. Obviously I am looking for some way to code the source file so that when anchors are followed, they are displayed as I want them to be. I can not change the destination file content (or name) -- that is already determined by its own needs.

I had hoped that the following HTML code would FORCE the browser responding to the anchor by treating the content as plain text: <a href="file:path" type="text/plain">anchor text</a>. Likewise: <a href="file:path" type="text/html">...</a> should FORCE the browser to treat the responding reference as HTML code. Firefox does this (good for you!). However, Google Chrome and Internet Explorer seem to ignore the given content type and treat the response according to however they feel (which seems to be according to the file extension). I was hoping to find a standard that describes how a browser handles a source-specified content type. I have looked at W3C's html and http standards and have yet to find any applicable description or requirement. Obviously I am looking for some way to code the source file so that when anchors are followed, they are displayed as I want them to be. I can not change the destination file content (or name) -- that is already determined by its own needs.

Gekose oplossing

Hi asicchecker, regarding what is "required", did you follow Gingerbread Man's links?

These are more direct:

HTML 4.01: http://www.w3.org/TR/html401/struct/links.html#h-12.2

HTML5: http://www.w3.org/TR/html5/links.html#attr-hyperlink-type (same)

MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-type

Lees dié antwoord in konteks 👍 1

All Replies (5)

more options

asicchecker wrote:

Google Chrome and Internet Explorer seem to ignore the given content type and treat the response according to however they feel (which seems to be according to the file extension).

Is your server not sending a Content-Type header? Does the document lack a meta content-type tag? Either of those could take precedence over the link's type attribute.

asicchecker wrote:

I have looked at W3C's html and http standards and have yet to find any applicable description or requirement.
more options

My Server is my browser (which I would also claim is my Client). When using a File scheme of the URI, the file requester (the browser when I click on an anchor) has no other http entity to from which to request the file. The browser gets the file locally from the operating system, and "returns" the file to itself. The same browser then renders the returned file according to some rule (including content type).

Perhaps the browser is supposed to send a Content-Type header to its own child process. If so, how could I tell?

more options

With a local file, there is no server response header to tell the browser what content-type the file is, so the browser has to use the extension name for that.

more options

Clearly, the browser does not "have to" use the extension. Firefox does not. Since Firefox (and any other browser) already "knows" that the anchor has been given a content-type, it can use that given type -- although some other browsers choose not to. Further, my question is whether or not this is required by some HTTP/HTML/Browser/URI/MIME standard (and if so, where).

more options

Gekose oplossing

Hi asicchecker, regarding what is "required", did you follow Gingerbread Man's links?

These are more direct:

HTML 4.01: http://www.w3.org/TR/html401/struct/links.html#h-12.2

HTML5: http://www.w3.org/TR/html5/links.html#attr-hyperlink-type (same)

MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-type