RK-
RK-

Reputation: 12211

Can we set style to title tag in header

Can we set style to title tag in header in html head as the following. I tried it did not work..

<title style="font-style:italic;"> My Title</title>

Upvotes: 11

Views: 19099

Answers (6)

user13518412
user13518412

Reputation: 7

You can't set style to title tag I had before also tried it. However you can style console (You can use two attributes in console.log).

For example, I log text WARNING! This website is not safe!" and style it I can do this:

console.log("%cWARNING! This website is not safe!%c", "font-color: red; font-weight: bold");

If I change the places of %c it will show text from the first %c to second %c into style.

Upvotes: 1

Mr.T.K
Mr.T.K

Reputation: 2356

You can't style the title (<title>) tag.

Upvotes: 1

Stijn de Witt
Stijn de Witt

Reputation: 42075

Try this CSS rule:

* {display:block}

On my Chrome browser, this makes the title (and script elements!) visible on the page. Still I don't think you want that. Normally we use h1 .. h6 for titles that need to be visible on the page itself.

Upvotes: 1

Quentin
Quentin

Reputation: 943564

You can apply CSS to the <title> element, but not though the style attribute (since it is for "All elements but BASE, BASEFONT, HEAD, HTML, META, PARAM, SCRIPT, STYLE, TITLE").

I'm not aware of any browser that will apply CSS for the rendering of the title in browser tabs or title bars though.

You can, however, do something like:

head { display: block; }
title { display: block; font-size: 200%; font-weight: bold; }

Upvotes: 13

Ankur
Ankur

Reputation: 33637

Unfortunately, the title is shown in the browser title bar and NOT on the page where styles get applied, so event if you set style on title tag, it wont have any effect

Upvotes: 2

Pekka
Pekka

Reputation: 449435

Nope. How the title is rendered is up to the browser.

Upvotes: 3

Related Questions