Twitter Baseline

Baseline is Twitter's toolkit for kickstarting CSS for websites, apps, and more. It includes base CSS styles for typography, forms, buttons, tables, grids, navigation, alerts, and more.

You can use Twitter Baseline in one of two ways: just drop the compiled CSS into any new project and start cranking, or run LESS on your site and compile on the fly like a boss.

1. Compiled CSS

Use this option if you want all the styles of Baseline, but none of the extra power of LESS.

<link type="text/css" href="css/Baseline.css" media="all" />

2. Run with LESS.js

Use this option to make full use of Baseline's LESS variables, mixins, and nesting in CSS.

<link rel="stylesheet/less" type="text/css" href="less/Baseline.less" media="all" />
<script type="text/javascript" src="js/less-1.0.41.min.js"></script>

Bootstrap is a super awesome pack of mixins and variables to be used in conjunction with LESS, a CSS preprocessor for faster and easier web development.

What's included

Here's a rundown of what's included in Twitter Baseline as part of Bootstrap. Head over to the Bootstrap website or Github project page to download and learn more.

Color variables

Variables in LESS are perfect for maintaining and updating your CSS. When you want to change a color value, update it in one spot and you're set.

// Links
@link-color:        #0069d6;
@link-hover-color:  darken(@link-color, 10);

// Grays
@white:             #fff;
@gray-lighter:      #ccc;
@gray-light:        #777;
@gray:              #555;
@gray-dark:         #333;
@black:             #000;

// Accent Colors
@blue:              #08b5fb;
@blue-dark:         #0069d6;
@green:             #46a546;
@red:               #9d261d;
@yellow:            #ffc40d;
@orange:            #f89406;
@pink:              #c3325f;
@purple:            #7a43b6;

Two Comment Styles

// This is a comment
/* No, this is a comment */

Mixins up the wazoo

// Font Stacks
.font(@weight: normal, @size: 14px, @lineheight: 20px) {
  font-size: @size;
  font-weight: @weight;
  line-height: @lineheight;
}
.sans-serif(@weight: normal, @size: 14px, @lineheight: 20px) {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: @size;
  font-weight: @weight;
  line-height: @lineheight;
}

// Drop shadows
.box-shadow(@shadow: 0 1px 3px rgba(0,0,0,.25)) {
  -webkit-box-shadow: @shadow;
  -moz-box-shadow: @shadow;
  box-shadow: @shadow;
}

// Gradients
#gradient {
  .horizontal(@startColor: #555, @endColor: #333) {
    background-color: @endColor;
    background-repeat: no-repeat;
    background-image: -webkit-gradient(linear, left top, right top, from(@startColor), to(@endColor));
    background-image: -webkit-linear-gradient(right center, @startColor, @endColor);
    background-image: -moz-linear-gradient(right center, @startColor, @endColor);
    background-image: -o-linear-gradient(left,  @startColor,  @endColor);
    background-image: -khtml-gradient(linear, left top, right top, from(@startColor), to(@endColor));
    filter: e(%("progid:DXImageTransform.Microsoft.Gradient(StartColorStr='%d', EndColorStr='%d', GradientType=1)",@startColor,@endColor));
    -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorStr='%d', EndColorStr='%d', GradientType=1))",@startColor,@endColor);
  }
  .vertical(@startColor: #555, @endColor: #333) {
    background-color: @endColor;
    background-repeat: no-repeat;
    background-image: -webkit-gradient(linear, left top, left bottom, from(@startColor), to(@endColor));
    background-image: -webkit-linear-gradient(@startColor, @endColor);
    background-image: -moz-linear-gradient(@startColor, @endColor);
    background-image: -o-linear-gradient(top,  @startColor,  @endColor);
    background-image: -khtml-gradient(linear, left top, left bottom, from(@startColor), to(@endColor));
    filter: e(%("progid:DXImageTransform.Microsoft.Gradient(StartColorStr='%d', EndColorStr='%d', GradientType=0)",@startColor,@endColor));
    -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorStr='%d', EndColorStr='%d', GradientType=0))",@startColor,@endColor);
  }
}

Operations and grid system

@grid_columns: 16;
@grid_column_width: 40px;
@grid_gutter_width: 20px;
.columns(@column_span: 1) {
  display: inline;
  float: left;
  width: (@grid_column_width * @column_span) + (@grid_gutter_width * (@column_span - 1));
  margin-left: @grid_gutter_width;
  &:first-child {
    margin-left: 0;
  }
}

Default Grid

The default grid system provided as part of Baseline is a 940px wide 16-column grid. It's a flavor of the popular 960 grid system, but without the additional margin/padding on the left and right sides.

Example grid markup

As shown here, a basic layout can be created with two "columns," each spanning a number of the 16 foundational columns we defined as part of our grid system. See the examples below for more variations.

<div class="row">
<div class="span6 columns">
...
</div>
<div class="span10 columns">
...
</div>
</div>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
3
3
3
3
3
1
4
4
4
4
4
6
6
8
8
5
11
16

Headings and copy

A standard typographic hierarchy for structuring your webpages.

h1. Heading 1

h2. Heading 2

h3. Heading 3

h4. Heading 4

h5. Heading 5
h6. Heading 6

Example paragraph (body text)

Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Misc. elements

Using emphasis, addresses, & abbreviations

<strong> <em> <address> <abbr>

When to use

Emphasis tags (<strong> and <em>) should be used to add visual distinction between a word or phrase and its surrounding copy. Use <strong> for plain old attention and <em> for slick attention and titles.

Emphasis in a paragraph

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Maecenas faucibus mollis interdum. Nulla vitae elit libero, a pharetra augue.

Addresses

The address element is used for—you guessed it!—addresses. Here's how it looks:

Twitter, Inc.
795 Folsom Ave, Suite 600
San Francisco, CA 94107
P: (123) 456-7890

Note: Each line in an address must end with a line-break (<br />) to properly structure the content as it is read in real life without any styles applied.

Abbreviations

For abbreviations and acronyms, use the abbr tag (acronym is deprecated in HTML5). Put the shorthand form within the tag and set a title for the complete name.

Blockquotes

<blockquote> <p> <cite>

Be sure to wrap your blockquote around paragraph and cite tags. When citing a source, use the cite element. The CSS will automatically preface a name with an em dash (&mdash;).

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

Dr. Julius Hibbert

Lists

Unordered <ul>

  • Jeremy Bixby
  • Robert Dezure
  • Josh Washington
  • Anton Capresi
  • My Team Mates
    • George Castanza
    • Jerry Seinfeld
    • Cosmo Kramer
    • Elaine Bennis
    • Newman
  • John Jacob
  • Paul Pierce
  • Kevin Garnett

Unstyled <ul.unstyled>

  • Jeremy Bixby
  • Robert Dezure
  • Josh Washington
  • Anton Capresi
  • My Team Mates
    • George Castanza
    • Jerry Seinfeld
    • Cosmo Kramer
    • Elaine Bennis
    • Newman
  • John Jacob
  • Paul Pierce
  • Kevin Garnett

Ordered lists <ol>

  1. Jeremy Bixby
  2. Robert Dezure
  3. Josh Washington
  4. Anton Capresi
  5. My Team Mates
    1. George Castanza
    2. Jerry Seinfeld
    3. Cosmo Kramer
    4. Elaine Bennis
    5. Newman
  6. John Jacob
  7. Paul Pierce
  8. Kevin Garnett

Description lists dl

Description lists
A description list is perfect for defining terms.
Your mom
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
And your dad
Etiam porta sem malesuada magna mollis euismod.

Building tables

<table> <thead> <tbody> <tr> <th> <td> <colspan> <caption>

Tables are great—for a lot of things. Great tables, however, need a bit of markup love to be useful, scalable, and readable (at the code level). Here are a few tips to help.

Always wrap your column headers in a thead such that hierarchy is thead > tr > th.

Similar to the column headers, all your table's body content should be wrapped in a tbody so your hierarchy is tbody > tr > td.

Example: Default table styles

All tables will be automatically styled with only the essential borders to ensure readability and maintain structure. No need to add extra classes or attributes.

# First Name Last Name Language
1 Your Mom English
2 Joe Sixpack English
3 Stu Dent Code
<table class="common-table">
  ...
</table>

Example: Zebra-striped

Get a little fancy with your tables by adding zebra-striping—just add the .zebra-striped class.

# First Name Last Name Language
1 Your Mom English
2 Joe Sixpack English
3 Stu Dent Code
<table class="common-table zebra-striped">
...
</table>

Example: Zebra-striped w/ TableSorter.js

Taking the previous example, we improve the usefulness of our tables by providing sorting functionality via jQuery and the Tablesorter plugin. Click any column's header to change the sort.

# First Name Last Name Language
1 Your Mom English
2 Joe Sixpack English
3 Stu Dent Code
<script type="text/javascript" src="js/jquery/jquery.tablesorter.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $("table#sortTableExample").tablesorter( {sortList: [[1,0]]} );
  });
</script>
<table class="common-table zebra-striped">
  ...
</table>

All forms are given default styles to present them in a readable and scalable way.

Example form legend
Some Value Here
Example form legend
@
Example form legend
Note: Labels surround all the options for much larger click areas and a more usable form.
to All times are shown as Pacific Standard Time (GMT -08:00).
Block of help text to describe the field above if need be.

Buttons

As a convention, buttons are used for actions while links are used for objects. For instance, "Download" could be a button and "recent activity" could be a link.

All buttons default to a light gray style, but a blue .primary class is available. Plus, rolling your own styles is easy peasy.

Example buttons

Button styles can be applied to anything with the .btn applied. Typically you'll want to apply these to only a, button, and select input elements. Here's how it looks:

Alternate sizes

Fancy larger or smaller buttons? Have at it!

Tabs or pills?

Create simple secondary navigation with a ul. Swap between tabs or pills by adding the appropriate class.

Great for sub-sections of content like our account settings pages and user timelines for toggling between pages of like content. Available in tabbed or pill styles.

<ul class="tabs">
  <li class="active"><a href="">Home</a></li>
  <li><a href="">Profile</a></li>
  <li><a href="">Messages</a></li>
  <li><a href="">Settings</a></li>
  <li><a href="">Contact</a></li>
</ul>
<ul class="pills">
  <li class="active"><a href="">Home</a></li>
  <li><a href="">Profile</a></li>
  <li><a href="">Messages</a></li>
  <li><a href="">Settings</a></li>
  <li><a href="">Contact</a></li>
</ul>

Pagination

Ultra simplistic and minimally styled pagination inspired by Rdio. The large block is hard to miss, easily scalable, and provides large click areas.

<div class="pagination">
  <ul>
    <li class="prev disabled"><a href="">&larr; Previous</a></li>
    <li class="active"><a href="">1</a></li>
    <li><a href="">2</a></li>
    <li><a href="">3</a></li>
    <li><a href="">4</a></li>
    <li><a href="">5</a></li>
    <li class="next"><a href="">Next &rarr;</a></li>
  </ul>
</div>

Basic alerts

One-line messages for highlighting the failure, possible failure, or success of an action. Particularly useful for forms.

×

Oh snap! Change this and that and try again.

×

Holy gaucamole! Best check yo self, you're not looking too good.

×

Well done! You successfully read this alert message.

×

Heads up! This is an alert that needs your attention, but it's not a huge priority just yet.

Block messages

For messages that require a bit of explanation, we have paragraph style alerts. These are perfect for bubbling up longer error messages, warning a user of a pending action, or just presenting information for more emphasis on the page.

×

Oh snap! You got an error! Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Take This Action Or Do This

×

Holy gaucamole! This is a warning! Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

Take This Action Or Do This

×

Well done! You successfully read this alert message. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas faucibus mollis interdum.

Take This Action Or Do This

×

Heads up! This is an alert that needs your attention, but it's not a huge priority just yet.

Take This Action Or Do This