<code> element incorrectly styled as a block element

Bug #1262217 reported by Matthew Paul Thomas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-website-content
Fix Released
Low
Anthony Dillon

Bug Description

In <http://design.canonical.com/2010/04/notification-area/>, the names "systray.exe" (twice), "fast-user-switch-applet", "nm-applet", and so on are incorrectly presented in coloured blocks by themselves, even though they're in the middle of sentences.

This is because of an error in <http://design.canonical.com/wp-content/themes/design-blog-theme/assets/stylesheets/core.css>. It contains:

    code, pre {
      background-color: #FDF6F2;
      -webkit-border-radius: 4px;
      -moz-border-radius: 4px;
      display: block;
      border-radius: 4px;
      font-family: "Ubuntu Monospace", "Ubuntu Mono Regular", "Lucida Console", "Monaco",
        "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier,
        monospace;
      font-size: .8em;
      padding: 1.25em;
      margin-bottom: 1.25em;
    }
    code {
      margin-top: 1.25em;
    }

The <code> element is a phrasing element -- the same as <b>, <i>, <em>, <var>, and so on -- so it should not be styled with {display: block}, or any of the border, background, or margin properties that assume it is a block. <http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element> <http://www.w3.org/TR/html5/dom.html#phrasing-content-1>

This could be fixed as follows:

    code, pre {
      font-family: "Ubuntu Monospace", "Ubuntu Mono Regular", "Lucida Console", "Monaco",
        "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier,
        monospace;
      font-size: .8em;
    }
    pre {
      background-color: #FDF6F2;
      border-radius: 4px;
      margin: 1.25em 0;
      padding: 1.25em;
    }

Related branches

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

www.ubuntu.com avoids the same mistake, but only narrowly. From
<http://assets.ubuntu.com/sites/guidelines/css/latest/ubuntu-styles.css>:

    code,li,p,pre{
      font-size:1em;
      margin-bottom:.75em;
      line-height:1.6;
      margin-bottom:.75em
    }

In the case of <code>, the margin declarations are no-ops, because <code> is an inline element, not a block element. The only effective declaration is the {line-height: 1.6}, and that probably doesn't do what its creator thought it would! "code," would best be removed from that selector as well.

information type: Proprietary → Public
Changed in ubuntu-website-content:
assignee: nobody → Graham Bancroft (gbancroft-canonical)
Changed in ubuntu-website-content:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Updated core.css. Waiting for a ticket to push it live.

Changed in ubuntu-website-content:
assignee: Graham Bancroft (gbancroft-canonical) → Anthony Dillon (ya-bo-ng)
status: Confirmed → Fix Committed
Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

This is live.

Changed in ubuntu-website-content:
status: Fix Committed → Fix Released
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Verified. Thank you!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.