48

What is the length limitation of HTML title attribute?

<span title="some big long piece of text and is there any limit to its size?" />

Edit:

My question is specific to title attribute not general

ArK
  • 20,698
  • 67
  • 109
  • 136
  • Possible duplicate of [Is there a limit to the length of HTML attributes?](http://stackoverflow.com/questions/1496096/is-there-a-limit-to-the-length-of-html-attributes) – user May 10 '16 at 20:52

6 Answers6

41

Titles are limited to 512 total characters in internet explorer according to MSDN.

http://msdn.microsoft.com/en-us/library/ie/ms534683(v=vs.85).aspx

Ashkan
  • 616
  • 1
  • 9
  • 15
19

I just tried this out for Chrome, Safari, and Firefox with HTML5:

Chrome limits to 1024.

Safari had no limit (I tried up to 3250)

Firefox also had no limit up to 3250. As @jukka mentioned, though, Firefox does not automatically insert linebreaks.

Jonathan Basile
  • 649
  • 1
  • 10
  • 20
  • 1
    I should mention though that I had a site with title tags ~3200 characters in length, and had to get rid of them because any browser running on a Windows computer would experience freezing when the title tags tried to appear. – Jonathan Basile Jun 23 '15 at 02:57
  • 3
    Update Sep 2017: Last version of Chrome (61) still limits to exactly 1024 chars. – cprcrack Sep 28 '17 at 10:38
6

There is no length limitation in either HTML 4.01 or HTML5, although long tooltips are usually a sign that you should be placing that text elsewhere, possibly before or after. (I said "usually" because xkcd uses the tooltips effectively, though the description could still be put underneath the image with the same relative effect.)

Kevin Ji
  • 10,479
  • 4
  • 40
  • 63
  • 2
    hey are you talking about tag . i mean attribute – ArK Dec 15 '11 at 07:08
  • 1
    @Paniyar Don't edit the post making only half of it relevant to your answer and radically changing its meaning. Once the answerer sees your comment, they can update it if they wish. – Andrew Marshall Dec 15 '11 at 07:11
  • @Andrew Marshall thanks but by checking second link only i'm able to identify about his wrong interpretation. – ArK Dec 15 '11 at 07:15
  • @AndrewMarshall Sorry about misinterpreting the question, I've corrected my answer. – Kevin Ji Dec 15 '11 at 20:31
  • 1
    Actually IE has a limit of 512 characters for HTML 4.01. Check: http://stackoverflow.com/questions/12139904/query-about-html-title-attribute/12140118#12140118 – mas_oz2k1 Mar 26 '13 at 23:17
6

There is no limit in the specifications, but when you go past 48 characters, browsers will treat it differently—IE breaks the text to two or more lines, whereas Firefox doesn’t. Firefox doesn’t honor explicit line breaks in source (this is, debatably, correct behavior).

So the practical conclusion is: if you need to ask, it’s too long, and you should use some other technique. The title attribute is normally used for the “tooltip” effect, and similar effects can be created (with better usability) using CSS (and possibly JavaScript).

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
2

The implementation in browsers differ but I think HTML 4.01 is 128 chars. I've seen limits from 80 chars up to 2000 being mentioned on the web.

span
  • 5,405
  • 9
  • 57
  • 115
0

According W3C,

The title should ideally be less than 64 characters in length. That is, many applications will display document titles in window titles, menus, etc where there is only limited room. Whilst there is no limit on the length of a title (as it may be automatically generated from other data), information providers are warned that it may be truncated if long.

Check it out: The TITLE element in HTML

Community
  • 1
  • 1
Roman Newaza
  • 11,405
  • 11
  • 58
  • 89