How can I have a Blank Title Page?
Asked Answered
B

2

14

I'm using

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8"/>
    <script>document.title=" ";</script>
  </head>
</html>

It works in IE and Firefox, but Chrome doesn't work. Well, in W3C standard. It seems that blank title is not allowed?!

User agents should use the document's title when referring to the document in their user interface. When the contents of a title element are used in this way, the directionality of that title element should be used to set the directionality of the document's title in the user interface.

Bantustan answered 9/5, 2014 at 3:47 Comment(0)
A
28

According to HTML5 CR, the title element is required, unless “the document is an iframe srcdoc document or if title information is available from a higher-level protocol” (this is specified in the description of the head element).

It is possible to set the title in JavaScript by an assignment to document.title, in practice and according to HTML5 CR. Of course, this is ineffective for many important uses of the title, since this only takes place in a browser.

HTML5 CR also specifies that the title element must not be empty or contain just a space. More exactly, the content must be text that is not inter-element whitespace.

There is no corresponding requirement for the value of document.title. However, HTML5 specifies that on assignment, leading and trailing whitespace is stripped off. If you test the value of document.title after the assignment document.title = " ", you will see that the value is the empty string, not a space.

Browsers differ in what they do with the document title (set with a <title> element or via assignment to document.title). They may display it in various ways in their user interface. If the title is set to the empty string or is not set at all, browsers typicallty use the file name of the document, possibly somehow modified, in place of a title. This is what happens e.g. in Chrome, Firefox, and IE (on Windows) when they show document title as the name of a tab. (I don’t know what the question means by saying that setting title blank “works” in IE and Chrome.)

In most cases, an empty title for a document makes no sense, any more than it would make sense to publish a book without a name. But if you have a use case where you want to make the title (as shown by browsers in some contexts), you can deploy various tricks.

For example, NO-BREAK SPACE U+00A0 is by definition not a whitespace character in HTML, so you could use <title>&nbsp;</title> in HTML or document.title='\u00A0' in JavaScript. The title will then look like blank, but it’s technically not empty, so it will be used browsers.

Since NO-BREAK still occupies space (it’s really shown with a glyph, just a completely blank glyph), you might use LEFT-TO-RIGHT MARK U+200E instead; it is an invisible (zero-width) control character. In HTML, you could use <title>&lrm;</title>. Alternatively, you could use document.title='\u200E' in JavaScript.

Arbogast answered 9/5, 2014 at 6:57 Comment(4)
Well, what I mean is in IE and Firefox, the script title setting functions, but Chrome still keeps showing the filename in title tab. I have tried your sample with &lrm; which make all browsers with the blank title :). I understand W3C standard, it is just occasionally that I found the different parsing title in browsers.Bantustan
One more question. \u200E is not in ASCII set. It should be a messey code in chraset wit 'us-ascii'; however, all browsers converts it correctly. Why?Bantustan
@Dotku, \u200E is parsed by the JavaScript interpreter of the browser, according to JavaScript rules. The parsed character is then included in a string in the DOM. The character encoding of the document does not matter here; it only matters in HTML parsing, which has already taken place when JavaScript starts executing.Arbogast
<title>&lrm;</title> works at the moment in Chrome - <title>&nbsp;</title> shows &nbsp; not a blankGanda
C
7

chrome 76, macos 13 may 2019:

<title>&lrm;</title>

works, and here is a full example for an empty jekyll page with no tab title:

---
layout: null
---

<link href="http://localhostdotdev.com/favicon.ico" rel="icon" type="image/x-icon" />
<title>&lrm;</title>
<style>body { background-color: rgb(40, 44, 47) }</style>

(also has an empty favicon and a dark background that matches chrome's dark mode)

no title no favicon tab chrome

Contributor answered 13/5, 2019 at 2:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.