Ticket #1371 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 1 year ago

Allowing HTML in post titles

Reported by: MaThIbUs Assigned to: MathiasBynens
Priority: lowest Milestone:
Component: Template Version: 2.3
Severity: minor Keywords: dev-feedback 2nd-opinion
Cc:

Description

http://comox.textdrive.com/pipermail/hackers/2004-August/001119.html

http://mathibus.com/archives/2005/05/15/html-in-post-titles/#comment-3

WordPress doesn't allow you to embed HTML in your posts's titles. In fact, this is not a WordPress problem, it's more a lack of usability in Kubrick, the default WP theme. So, unless you're following Anne van Kesteren's "A header should not be a link, stupid!" logic, there is no way to embed code in your posts's titles without breaking the title attributes of a certain amount of links, thus making your pages invalid.

Attachments

html-in-post-titles.diff (2.9 kB) - added by MaThIbUs on 05/21/05 06:39:11.
html-in-post-titles.patch (2.9 kB) - added by MaThIbUs on 05/21/05 06:39:11.
html-in-post-titles.2.diff (3.8 kB) - added by MathiasBynens on 06/13/05 19:57:02.
The final patch.

Change History

05/15/05 16:58:12 changed by MaThIbUs

  • Patch set to No.

05/16/05 14:28:12 changed by MaThIbUs

Whoops, uploaded the patch file as html-in-post-titles.patch instead of with the .diff extension. Not sure if this makes any difference, though. Anyway, I uploaded the .diff file as well. Enjoy

05/21/05 06:39:11 changed by MaThIbUs

  • attachment html-in-post-titles.patch added.

06/13/05 19:57:02 changed by MathiasBynens

  • attachment html-in-post-titles.2.diff added.

The final patch.

06/13/05 19:59:01 changed by MathiasBynens

  • keywords set to kubrick title attribute html validation.
  • milestone set to 1.5.2.

Please ignore all files but html-in-post-titles.2.diff.

06/18/05 07:04:13 changed by MathiasBynens

  • priority changed from normal to high.
  • version changed from 1.5.1.1 to 1.5.2.

06/18/05 07:07:06 changed by MathiasBynens

  • owner changed from anonymous to MathiasBynens.

06/30/05 03:18:54 changed by markjaquith

  • priority changed from high to low.

06/30/05 18:13:31 changed by markjaquith

  • keywords changed from kubrick title attribute html validation to kubrick title attribute html validation bg|dev-feedback bg|2nd-opinion.

Passed to devs for feedback.

(follow-up: ↓ 25 ) 08/23/05 15:08:41 changed by davidhouse

I say include it. Those that don't want HTML in their titles can simply not use any.

08/29/05 16:38:24 changed by MathiasBynens

My point exactly.

09/30/05 17:36:00 changed by error

$strip should default to true, not false, for backward compatibility with themes that don't understand this field. Otherwise you're going to get odd breakage in quite a few themes.

11/13/05 02:40:23 changed by matt

  • priority changed from low to lowest.
  • milestone changed from 1.6 to 2.1.

06/02/06 21:22:22 changed by ranchnachos

As a non-developer and a large user of wordpress, I have to say this idea is rediculous. I can understand that this probably is an easy fix, but if you want to style post titles, that's what you use CSS for.

Adding support for post titles will just add more cruft to users' web pages. It's suppose to be about seperation of style from content, not allowing them to style their content directly from the editor, which is the complete opposite of everything Wordpress stands for(in my opinion, of course).

Just my .02

08/14/06 19:47:56 changed by rgovostes

  • keywords changed from kubrick title attribute html validation bg|dev-feedback bg|2nd-opinion to kubrick title attribute html validation bg|dev-feedback bg|2nd-opinion has-patch.

11/29/06 20:48:05 changed by matt

  • milestone changed from 2.1 to 2.2.

02/15/07 22:14:18 changed by rob1n

  • keywords changed from kubrick title attribute html validation bg|dev-feedback bg|2nd-opinion has-patch to dev-feedback 2nd-opinion.
  • version changed from 1.5.2 to 2.1.
  • severity changed from normal to minor.

02/21/07 05:17:05 changed by rob1n

I'm for marking this as wontfix. Post titles aren't meant to have HTML...

02/28/07 11:48:26 changed by Martin10

I agree with rob1n. No HTML in titles.

02/28/07 13:56:58 changed by Nazgul

  • status changed from new to closed.
  • resolution set to wontfix.
  • milestone deleted.

Closing as wontfix, because: - The general reponse on the ticket was negative. - The given patch would result in attributes containg html tags, which is invalid xhtml.

(follow-up: ↓ 20 ) 05/30/07 15:19:02 changed by ManxStef

  • status changed from closed to reopened.
  • resolution deleted.

Post titles aren't meant to have HTML? Why not? You are allowed to use HTML in each post's body but not its title? That's rather arbitrarily restrictive, don't you think?

The case for allowing HTML in posts' titles is a strong one. Primarily, allowing a post's title to contain HTML would be very useful and make WordPress more flexible. Why anyone would be against this is beyond me.

Most uses of the_title() when it comes to markup involve wrapping it in a heading element (h1,h2,h3,h4,h5,h6). According to my reading of the XHTML 1.0 & 1.1 Specifications there are many valid child elements that are allowed inside heading elements, so the potential is definitely there.

For instance, say you'd like to put emphasis on a particular word in the title, what's wrong with using the "em" element? What about if you're talking about say, the C standard library, and your post's title contains "#include <stdio.h>" and you'd like to wrap this in a "code" element? What if you wish to wrap a particular part of your title's text with a "span" so you can style it separately with CSS? There are many, many other perfectly legitimate uses.

CSS alone cannot give enough control over the styling of a header in many cases, the examples I've given show as much, and the fact the the XHTML specs allow for child elements inside heading elements shows that they realise this, too.

Of course there are also instances where you then don't want the HTML to show up, which is why this patch is necessary. For instance, Kubrick's handling of the title of the hyperlink to each post's title i.e. (line 10 of index.php)

<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>

The "a" element's title parameter will potentially invalidate the entire page's code if a post's title currently contains markup. This is bad.

Therefore, a cautious "no-HTML by default" approach to the_title() would be good and is exactly what this patch would provide, allowing older themes to continue to function while providing the means for newer themes to take advantage of the extra functionality.

As such, I'm in STRONGLY in favour of this patch to the_title(), it'd definitely help people do perfectly valid things with post titles that they currently can't.

(in reply to: ↑ 19 ; follow-up: ↓ 21 ) 05/30/07 15:44:31 changed by Otto42

Replying to ManxStef:

Post titles aren't meant to have HTML? Why not? You are allowed to use HTML in each post's body but not its title? That's rather arbitrarily restrictive, don't you think?

No, it goes with the whole separation of content and style thing. HTML in the post body is a) restricted to certain privileged users and b) heavily filtered. It's one thing to allow body text to have tags like em and strong and such, but it's another to allow them in post titles and then have to deal with all the hassle of filtering them and dealing with the weird permalink issues that it would probably cause.

The case for allowing HTML in posts' titles is a strong one. Primarily, allowing a post's title to contain HTML would be very useful and make WordPress more flexible. Why anyone would be against this is beyond me.

Because it makes no sense. If you want to style the post titles, then use the CSS file. That's what it's for. Unless you want to style each post title separately or in different colors or something, which seems like a bit of an edge case.

Most uses of the_title() when it comes to markup involve wrapping it in a heading element (h1,h2,h3,h4,h5,h6). According to my reading of the XHTML 1.0 & 1.1 Specifications there are many valid child elements that are allowed inside heading elements, so the potential is definitely there.

Then those elements should be in the template, not in the data. The data layer should be *just* the data, not the style as well. Presentation vs. content. HTML tags are only content in certain, very-limited, cases.

If we heavily filter the title (perhaps with kses) and don't allow arbitrary code for *any* user, and then always make the_title() and get_the_title() filter *ALL* HTML code out by default with only an option to display it if the theme allows it, then *maybe* your notion would work.

But I'm still +1 for not ever allowing HTML unless you can show me a legitimate example of why it would be useful that is not completely arbitrary in nature. Just putting some title words in italics or using separate styling for each title doesn't strike me as reason enough to add all the extra filtering overhead and violating the content/presentation layer concept.

(in reply to: ↑ 20 ) 05/30/07 16:57:30 changed by foolswisdom

  • version changed from 2.1 to 2.3.

Replying to Otto42:

Replying to ManxStef:

Post titles aren't meant to have HTML? Why not? You are allowed to use HTML in each post's body but not its title? That's rather arbitrarily restrictive, don't you think?

No, it goes with the whole separation of content and style thing. HTML in the post body is a) restricted to certain privileged users and b) heavily filtered. It's one thing to allow body text to have tags like em and strong and such, but it's another to allow them in post titles and then have to deal with all the hassle of filtering them and dealing with the weird permalink issues that it would probably cause.

I think including XML or HTML sounds good in theory, but I don't think it is a problem currently worth solving.

Replying to Nazgul:

Closing as wontfix, because: - The general reponse on the ticket was negative. - The given patch would result in attributes containg html tags, which is invalid xhtml.

06/12/07 22:18:24 changed by Nazgul

  • status changed from reopened to closed.
  • resolution set to wontfix.

Reclosing as wontfix based on the last couple of replies.

08/07/07 14:15:19 changed by JoostdeValk

  • status changed from closed to reopened.
  • resolution deleted.

I think there are certain html values with should be allowed in title's, the first two that come to mind being <abbr> and <acronym>...

08/10/07 19:12:34 changed by foolswisdom

  • milestone set to 2.4 (future).

(in reply to: ↑ 8 ) 09/24/07 07:04:28 changed by f00f

Replying to davidhouse:

I say include it. Those that don't want HTML in their titles can simply not use any.

I don't want HTML in the titles of my blog. But having several authors your "if you don't want it don't use it" policy probably would not be enough.

But besides that I don't see the point in having HTML in titles.

(follow-up: ↓ 27 ) 10/06/07 22:24:40 changed by thee17

I'm voting -1 just for the occasion that this would break the RSS. And also the what if someone puts a </div> or something that will break the page.

(in reply to: ↑ 26 ) 10/08/07 07:43:36 changed by JeremyVisser

Replying to thee17:

I'm voting -1 just for the occasion that this would break the RSS. And also the what if someone puts a </div> or something that will break the page.

This reason is not really valid, because any time that user HTML input is accepted, it would be run through the balance_tags() function which would make sure that your scenario would never happen.

10/08/07 08:36:18 changed by Otto42

  • status changed from reopened to closed.
  • resolution set to wontfix.

It's still going to break the RSS, and several themes. Again, nobody has really explained why they want HTML in post titles. All cases for it are very edge cases, the title is text only for a very good reason. That reason being that it's used in places where HTML is unacceptable.

It's a title, not HTML output. It's not guaranteed to be output as a webpage.

Closing as wontfix for the third time. Unless somebody can make a really compelling case, I suggest that this remain closed.

10/08/07 08:36:24 changed by Otto42

  • milestone deleted.