14

Is it possible to strike the title

<title><s>My Title</s></title>

like this, so that the titlebar will show My Title? Or is there a way to solve this with css?

4

8 に答える 8

19

From MDN on the <title> element:

The HTML Title Element defines the title of the document, shown in a browser's title bar or on the page's tab. It can only contain text and any contained tags are not interpreted.

So no, it cannot be done like that.

Update:

Other answers suggest using various combinations of unicode characters to accomplish a strike through, and even though that might be possible and could yield a decent result, I believe it comes with a large drawback.

I'm not an expert in SEO in any way, but from what I know, and according to Googles Search Engine Optimization Starters Guide the <title> is of great importance when it comes to search engine optimization. Their guide suggest that you should avoid:

  • Choosing a title that has no relation to the content on the page
  • Using default or vague titles like "Untitled" or "New Page 1"

My interpretation would be that using obscure characters in your title would be a direct violation of that, so based on that I would strongly suggest that you avoid it.

于 2012-10-30T15:44:42.850 に答える
13

This is possible by using characters that have a strike built into them. But this is the only way. Using HTML markup or CSS will not yield the result you want.

Example using this: http://blog.imthy.com/2008/06/strikethrough-strikethrough-text.html

于 2012-10-30T15:49:32.133 に答える
3

No, no browser known to me supports HTML rendering directly in the title bar, just the plaintext within the <title> tag will be displayed. The most you could hope to do is use some obscure characters where the line is part of each char - something very specific and something I care not to investigate.

于 2012-10-30T15:44:32.473 に答える
1

It is not possible to change the rendering of the title element content in the title bar, if it is displayed there. This does not depend on specifications but on implementations: browsers use their own routines to display the title, and HTML markup or CSS settings do not affect this.

Nothing prevents us from styling the title element as such, e.g.

title { text-decoration:line-through; }

but this has by default no visible effect, since the element is not part of the displayed document content. Adding

head, title { display: block; }

makes it visible, and you can see (in modern browsers) the content as overstruck on the page. But this does not affect the title bar (and isn’t particularly useful).

Using special characters in the element content, you can create overstriking as shown in other answers. This will however create a considerable risk of messing things up, because the routines that browsers use to display title bars often use a limited character repertoire, showing unsupported characters e.g. as small boxes.

于 2012-10-30T18:13:26.027 に答える
1

You could use Unicode combining characters to add them. It will depend heavily on the font the OS/browser is using in the title bar on how it looks though.

function strike(text) {
    var output = '';
    for (var i = 0; i < text.length; i++) {
        output += '\u0336' + text[i];
    }
    return output;
}

function strikeTitle() {
   document.title = strike(document.title);
}

EDIT: Personally I like \u0337 the best.

于 2012-10-30T18:56:28.430 に答える
0

ブラウザでは、2つのオプションを使用してドキュメントのタイトルをカスタマイズできます

  1. ファビコンアイコン2.タイトル

タグまたはcssを使用したカスタマイズは無視され、タイトルにはテキストとファブアイコンのみが表示されます。

そのため、タイトルをいじりたい場合でも、JavaScriptを使用して、自分に合ったアニメーションを作成できます。

于 2012-10-30T15:59:44.537 に答える
0

I'm afraid this isn't possible. The 'title' tag does not allow for any kind of formatting in its contents.

于 2012-10-30T15:45:20.833 に答える
0

this is not possible, you can not control the <title> tag of a browsers window title with CSS.

于 2012-10-30T15:49:27.493 に答える