Should titles contain emphasis (em) tags?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
miro_dietiker's picture

There's a key question in the air about appearance of drupal titles.
The question is if replaced elements if a title/heading (h1) should contain emphasis (em) or no.

In Drupal core are several examples for pro and con. The title appears also as browser title.

Samples are: (percentage variables replaced as plain text in this sample)

<h1>Configure <em>%format</em></h1>
<h1>Top pages in the past <em>%interval</em></h1>
<h1>Translations of <em>%title</em></h1>

A clear pro is: replacements could be visually identified by the user. Emphasis appear typically italic in bold titles.

A con is: The tags need to be stripped for browser title presentation... (well that's no real con from architecture point of view, just a todo).
Currently there are repeating issues because of inconsistencies regarding this and regarding theming misbehaviour.

Removing emphasis completely would result in unability to identify the whole replacement part in the title and possibly misunderstanding the title.
Leading to: (percentage variables replaced as plain text in this sample)

<h1>Configure %format</h1>
<h1>Top pages in the past %interval</h1>
<h1>Translations of %title</h1>

As per XHTML 1.0 Transitional standard, em is allowed in h1 and therefore in my opinion we shouldn't strip too many things too early.
This decision is leading to global updates on the core.

What do you think about?

Comments

Browser title

Dave Reid's picture

The web browser's title should always be fine since template_preprocess_page performs the following on the header:

<?php
$head_title
= array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
?>

Senior Drupal Developer for Lullabot | www.davereid.net | @davereid

Broken themes & recent discussions

miro_dietiker's picture

I've recently seen theme acquia_marina to rebuild $head_title in an individual manner.
It was building $head_title from variable_get('site_name', 'Drupal') and missed to strip itself again..

But indeed there are also other broken themes. Thus leading to many modules having entries like "em shows up in title! please remove!". Honestly i found myself in posting such a (wrongly addressed) issue report due to the acquia_marina right before the argumentation began and led to this post.
Some module maintainers even consider using % in conjunction with titles as wrong.
I already proposed to change the samples on function t() leading to use % instead of @ for title. But still there's no agreement on its usage.

I've attached the occurences of core regarding drupal_set_title in conjunction with % or @:
http://drupalbin.com/4405

Today we where argueing with "Heine" and originator of "make drupal_set_title use check_plain by default" http://drupal.org/node/242873 pwolanin which is related to this request to find a common denominator for core module guidelines too.

For the drupal_set_title we agreed again that the check_plain for default and for security reasons make sense. However for all drupal_set_title after internal t() replacement, an additional PASS_THROUGH is required while it is very important not to pass this just by habit.

Interestingly the blog title was already once emphasized and was then removed (thanks Heine for pointing this out):
http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/blog/blog.module?r...

There was the argument to decide if a replacement could lead to misunderstanding and decide whether to use % or @ case by case. But since we're doing multilanguage outputs it is impossible to reside on a specific languages' appearance and make this as the right basis for deciding the usage % or @ or the ambiguity of final output.

So how do we exactly define a perfect guideline about this usage?

Usability

Group organizers

Group categories

UX topics

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week