About BareCSS
What is it?
BareCSS is a CSS only framework that styles frequently used HTML tags without the need for classes. It also provides a few utilities such as a responsive grid and CSS only tooltips.
BareCSS can be used stand-alone or as a foundation to build upon. This site you're viewing now uses BareCSS and a custom style sheet that's less than 3kb.
Compatible with all modern browsers and IE9+.
Checkout the continuation of BareCSS in CSS AMP.
Why does it exist?
Sometimes you want to quickly set up a simple site or application. You don't want it to look like a Word™ doc but you also don't want/need a massive framework such as Bootstrap or Foundation or Materialize.
So in a similar vein as Pure and Skeleton, BareCSS aims to provide a minimal CSS framework that requires minimal setup.
BareCSS takes this minimal approach one step further by making it completely classless. Not only that, but the default styles are only applied to elements without classes. Why only bare tags? For custom components and modules, you may not want the standard stylings to apply, so by giving them a class you're removing all Bare styling. If you want to add a class and want the Bare styling applied, just add the xx attribute to that element.
How does it work?
CSSAMP effectively changes the default browser styles. Any commonly used tags such as input or button are styled only if they don't have any classes.
What if you want to add a class to a tag but still want to retain the CSSAMP style? Just add the attribute data-xx to the tag and the CSSAMP styles will be applied.
<!-- want to style a button? -->
<button>Button</button>
<!-- adding a class will remove the CSSAMP styling and use the default browser style -->
<button class="your-btn-class">Button</button>
<!-- adding the attribute data-xx to a tag with a class will apply the CSSAMP styling -->
<button data-xx class="your-btn-class">Button</button>
Is BareCSS Dead?
BareCSS has not been updated in some time, and is unlikely to be.
It has been forked into a few further projects, and this site is here to maintain the original presence. CSSAMP is a replacement that includes the AMP framework but otherwise works similarly in a more modern way. No classes still, but it validates completely and works well on mobile and the rest.
CSSAMP is created as a single-file solution with inline SVG graphics for maximum speed.
Change log
v1.1.0
- Removed all classes (note: this is a breaking change)
- Grids no longer use classes
- Buttons no longer use classes
- Cards no longer use classes
- The
xxdefault class has now been made an attribute - Changed utility classes to attributes
- Introduced tags
- Introduced rounded buttons
- Changed tooltip behaviour and attribute
- Instead of
data-ttit's now justtt - Anchor link tooltips now require the
attattribute
- Instead of
- Introduced footer
- Includes a template HTML file
v1.0.1
- Added navigation
- Separated LESS files into components
- Included SVG icons
How to install
Download the package from Github.
Included are SVG icon files from Google, the compiled and minified CSS file, and the LESS components.
If there are any components you don't need, just comment the line out from bare.less and compile yourself.
A template.html file is included to help you get started with the basic structure of the nav and grid.
What's included:
BareCSS/
├── template.html
├── css/
│ └── bare.min.css
├── icons/
│ ├── chevron-down.svg
│ ├── close.svg
│ ├── done.svg
│ └── hamburger.svg
└── less/
├── _anchor-link.less
├── _blockquote.less
├── _button.less
├── _card.less
├── _code.less
├── _footer.less
├── _grid.less
├── _input.less
├── _layout.less
├── _list.less
├── _navigation.less
├── _reset.less
├── _table.less
├── _tooltip.less
├── _transition.less
├── _typography.less
├── _utility-attributes.less
├── _variables.less
└── bare.less
Sections
This site that you're viewing right now is built on section elements. The sections are horizontally centred, have a max-width equal to the @width variable in the _variables.less file (default is 90rem), and will shrink with smaller screens. Useful for containing content quickly.
Note: Because of CSS specificity, overwriting the default style with a class will require specifying that the class applies to a section element. Eg: Your CSS property should look like section.custom-section rather than just .custom-section.
Typography
Font sizes in BareCSS are based in rems. You can set the initial font size in the html element to change the scale. The default is 10px so that 1rem is 10px and 2rem is 20px etc.
The font family defaults are just the standard browser defaults, so serif, sans-serif and monospace fonts are chosen by the browser. You can change this in the _variables.less file.
The main thing BareCSS does to headings is to standardise the margins and paddings. h1 through to h6 are catered for.
h1 Heading level 1
h2 Heading level 2
h3 Heading level 3
h4 Heading level 4
h5 Heading level 5
h6 Heading level 6
Tooltips
Tooltips are handy and BareCSS provides you with classless, no javascript tooltips. Tooltips can be applied to most tags, as long as they accept the ::before and ::after pseudo elements. Just use tt="Your tooltip here" in the tag.
Hover over this for a tooltip on a b tag. Hover over this, or this or even this to see tooltips in action.
Note: These tooltips aren't clever so they will spill offscreen. You'll need some Javascript if you want dynamic positioning.
Disabled button tooltips
If you want to tell your user why a button is disabled then you can use the dtt attribute to show a tooltip when a button is disabled. This is handy for things such as invalid or incomplete forms.
You can use both data-tt and data-dtt on the same element and the button disabled state will determine the tooltip shown.
Use the primary button to toggle the normal/disabled button.
Anchor link tooltip
You can easily set a tooltip for an anchor link that shows the href on hover just by adding the data-att attribute.
Forms
Nothing special here, replacing the often ugly browser defaults with some BareCSS style. Just note that you need to place the label tag directly after the radio and checkbox inputs. Text inputs and select boxes are default to 100% width as you'll most likely use them in a grid.
Code
The code tag functionality has been kept basic as you'll most likely be using something like PrismJS for syntax highlighting and code escaping.
Here is some inline code.
if ( to_be || !to_be )Blockquote
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris.
- Lorem Ipsum
Lists
As long as the ul or ol tag is classless or has the xx attribute the styles should apply to the child li elements too.
- Unordered list item one
- Unordered list item two
- Unordered list item three with nest list:
- Nested item one
- Nested item two
- Unordered list item four
- Ordered list item one
- Ordered list item two
- Ordered list item three with nest list:
- Nested item one
- Nested item two
- Ordered list item four
Tables
The tables are just your standard table element with thead, tbody, tr, th and td elements within. As long as the table tag is classless or with the xx attribute, the styles should apply to the child elements.
When the user hovers over the head row, the relevant column will be highlighted. Any other row and the entire row will be highlighted.
| Title one | Title two | Title three | Title four |
|---|---|---|---|
| Row 1 col 1 | Row 1 col 2 | Row 1 col 3 | Row 1 col 4 |
| Row 2 col 1 | Row 2 col 2 | Row 2 col 3 | Row 2 col 4 |
| Row 3 col 1 | Row 3 col 2 | Row 3 col 3 | Row 3 col 4 |
| Row 4 col 1 | Row 4 col 2 | Row 4 col 3 | Row 4 col 4 |
The grid
Getting a classless grid system in AMP requires using the standards compliant and totally working span element.
The CSSAMP grid is simple and succinct. It's also fully responsive so that's nice. Just use the span element and throw some divs with data-col attributed children in there and you're good. No need for row as the data-cols will wrap around.
Since there are no rows, column widths are expressed in fractions which should make identifying rows easier. Eg: 1/3 and 2/3 make a row.
Note that each column in this grid will be 100% width on a mobile device.
Fixed grids for mobile
The grid columns will automatically expand to 100% width when the viewport reaches the @mobile width. To prevent this, add the data-fx attribute to the column.
Nested grids
You can place a span inside of data-col to nest grids. You can do this as many times as you like.
Grids with horizontal rule
The examples you are looking at now are all cols within a span separated by hrs.
<!-- you can use a hr to separate cols -->
<span>
<div data-col="1/2"></div>
<div data-col="1/2"></div>
<hr>
<div data-col="1/2"></div>
<div data-col="1/2"></div>
</span>
Cards
Cards use the also totally non-compliant figure element but works fine in IE9+. These cards are meant to be used within a grid.
Card one
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Card two
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore.
Card three
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
<!-- figure element -->
<figure>
<p>Your content</p>
</figure>
<!-- card within a grid -->
<span>
<div data-col="1/2">
<figure>
<h5>Card title</h5>
<hr>
<p>Your content here</p>
</figure>
</div>
<div data-col="1/2">
<figure>
<h5>Card title</h5>
<hr>
<p>Your content here</p>
</figure>
</div>
</span>
Cards with images
Top image
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.
Middle image
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.
Bottom image
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.

Utility attributes
CSSAMP has a few utility attributes to make laying out a site a little faster. Sometimes you don't need to give an element a unique class to make it's text align right. Use these attributes to apply quick styles such as paddings or margins.
| Attribute | Values | Effect |
|---|---|---|
data-full | null | Width 100% |
data-hide | null | Display none |
data-fs | xs s m l xl | Sets font sizes from 1.1rem to 2.4rem |
data-mt | 0 2 4 8 | Sets margin-top from 0 to 8rem |
data-mb | 0 2 4 8 | Sets margin-bottom from 0 to 8rem |
data-pt | 0 2 4 8 | Sets padding-top from 0 to 8rem |
data-pb | 0 2 4 8 | Sets padding-bottom from 0 to 8rem |
data-pa | 0 2 | Either removes all padding or sets padding for all sides to 2rem |
data-txt | l c r j | Sets text alignment to left, center, right or justify |
<!-- margin top 2rem + margin bottom 4rem -->
<div data-mt="2" data-mb="4"></div>
<!-- padding all 2rem -->
<p data-pa="2"></p>
<!-- text align right + font size small -->
<p data-txt="r" fs="s"></p>