API: CSS: Buttons

nateemerson edited this page May 21, 2011 · 7 revisions
Clone this wiki locally


The .button-full entity and its variations form a button that spans the full width of a page. This button includes a gradient background using -moz and -webkit style attributes when possible, otherwise reverting to a solid color similar to the intended gradient. Depending on the way in which the entity and contained elements are marked up, the button will format itself as a one or two option button.

A variation on this, the <a#button-top> entity is available for non-linear browsers (standard and full devices) that positions a given link to be right-aligned within the page header, regardless of where the attribute resides in page markup.


The .button-full entity can be employed by any module to create a stand-alone object that links elsewhere in the system. Often, this entity is used to provide a back button or directional navigation buttons (next and previous) for a specific page. It is not intended to be used inside of a content area element such as a .content-full or .menu-full, but instead it should be used as a direct child of the body tag. To create a button inside a content area element, please see the documentation page for content: API: CSS: Content.

The #button-top entity can be employed by any module to create a stand-alone object that resides in the header and links elsewhere in the system. Often, this entity is used to provide a home button on a child page. It can be assigned to any <a> entity that will fit in a 16px by 85px space, as long as the <a> entity does not reside within a relatively positioned entity.

Example Code

Single Option Button

At the most basic level, a single option full width button can be created via <a.button-full>:

<a href="{LINK_URL}" class="button-full">{LINK_TEXT}</a>

Full Button

Derived from this markup is <a.button-full.button-padded>, a variation where the button appears as an entity padded from the edges of the browser with rounded corners when possible:

<a href="{LINK_URL}" class="button-full button-padded">{LINK_TEXT}</a>

Full Button with Padding

The framework also provides an alternate color scheme for buttons with <a.button-light>:

<a href="{LINK_URL}" class="button-full button-light button-padded">{LINK_TEXT}</a>

Light Full Button with Padding

Two Option Button

The framework also provides the ability to create a two option button using a <div.button-full> entity with child entities of <a.button-first> and <a.button-last>:

<div class="button-full">
    <a href="{LINK_URL_1}" class="button-first">{LINK_TEXT_1}</a>
    <a href="{LINK_URL_2}" class="button-last">{LINK_TEXT_2}</a>

As with a single option button, the two option button also supports .button-padded:

<div class="button-full button-padded">
    <a href="{LINK_URL_1}" class="button-first">{LINK_TEXT_1}</a>
    <a href="{LINK_URL_2}" class="button-last">{LINK_TEXT_2}</a>

Two Option Full Button with Padding

The <div.button-full> attribute also has support for a single button element:

<div class="button-full button-padded">
    <a href="{LINK_URL}" class="button-first button-last">{LINK_TEXT}</a>

The above method is completely interchangeable with the <a.button-full> markup described in the single option section.

For two item buttons, the .button-light attribute is assigned at the <a> level, not the <div> level:

<div class="button-full button-padded">
    <a href="{LINK_URL_1}" class="button-light button-first">{LINK_TEXT_1}</a>
    <a href="{LINK_URL_2}" class="button-light button-last">{LINK_TEXT_2}</a>

Two Option Light Full Button with Padding

The .button-light attribute may also be assigned to either option or both.

Top Button

Basic Use

At the most basic level, the <a#button-top> entity is defined as follows:

<a href="{LINK_URL}" id="button-top">{LINK_TEXT}</a>

Since the <a#button-top> entity leverages absolute positioning to position itself on the page, non-linear browsers (such as those found on T9 phones) will not be able to position the button correctly, and it will appear where ever you place the link in your markup. Use of the .not-basic class provides a mechanism for targeting only the non-linear browsers that support <a#button-top> positioning:

<a href="{LINK_URL}" id="button-top" class="not-basic">{LINK_TEXT}</a>

Recommended Use (Graceful Degradation)

The basic approach of <a#button-top.not-basic> works under most conditions, but for browsers that are not CSS compliant, graceful degradation is not possible. Furthermore, because basic browsers often need a home entity as well, the <a#button-top> entity is set up in such a way that it is fully compatible with <a.button-full> and its decorative styles.

<a href="{LINK_URL}" id="button-top" class="button-full button-padded">{LINK_TEXT}</a>

In this example the button will appear as a regular full width button on a linear browser, yet it will appear as a right-aligned button within the page <h1#header> entity on a non-linear browser.


DOM Technical Warning for #button-top

The <a#button-top> entity leverages absolute positioning to place itself within the <h1#header> entity. As such, <a#button-top> cannot reside within a parent entity that is positioned relatively, but instead required either a statically (default behavior for an entity) or absolutely positioned set of parent entities. Further, <a#button-top> should not be employed on a page that does not include <h1#header>.

W3C Markup Note for <a.button-full>

It is recommended by the W3C XHTML standard that an inline element <a> is always enclosed by a block element such as <div>. However, this is not required in the case of <a.button-full>, as the <a> entity is itself defined as a block-level element, so all styling and positioning is set correctly without a parent element. Also, note that it is recommended that all framework modules validate with the HTML 5 doctype rather than an XHTML doctype.