问题
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?
回答1:
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.
回答2:
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
回答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.
回答4:
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.
回答5:
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.
回答6:
I'm afraid this isn't possible. The 'title' tag does not allow for any kind of formatting in its contents.
回答7:
this is not possible, you can not control the <title>
tag of a browsers window title with CSS.
回答8:
Browser allows customization of the title of the document via two options
- Fav icon 2. Title
Any customization with tags or css wil be ignored and only text and fav icon will be displayed on the title.
so if you want to play around title, you can still do with javascript, you can create animations that might work for you.
来源:https://stackoverflow.com/questions/13142639/is-it-possible-to-strike-the-title-shown-in-the-title-bar