Typography
Right after being responsive, typography is the second most important thing in m.css. The m-components.css file styles the most often used HTML elements to make them look great by default.
Paragraphs, quotes and poems
Each <p>
element inside <main>
has the first line indented, is
justified and is separated from the following content by some padding. The
<blockquote>
elements are indented with a distinctive line on the left.
Because the indentation may look distracting for manually wrapped line blocks,
assign .m-poem
to such paragraph to indent all lines the same way. To
remove the indentation and justification altogether, use .m-noindent
.
Spacing between lines can be extended to 150% using .m-spacing-150
.
Lists, diaries
Ordered and unordered lists have padding on bottom only on the first level.
Mark the list with .m-unstyled
to remove the asterisks/numbers and
indentation.
It’s possible to convert a list to a single line with items separated by |
or •
to save vertical space on mobile devices and responsively change it
back on larger screens. Mark such list with .m-block-bar-*
or
.m-block-dot-*
:
Mark your definition list with .m-diary
to put the titles next to
definitions.
The lists are compact by default, wrap item content in <p>
to make them
inflated. Paragraphs in list items are neither indented nor justified.
Headings
The <h1>
is meant to be a page heading, thus it is styled a bit
differently — it’s bigger and has 1rem
padding after. The <h2>
to <h6>
are smaller and have just 0.5rem
padding after, to be
closer to the content that follows. Wrapping part of the heading in a
.m-thin
will make it appear thinner, depending on used CSS theme.
Transitions
Horizontal line is centered and fills 75% of the parent element. For a more
fancy transition, use .m-transition
on a paragraph.
Preformatted blocks
The <pre>
element preserves your whitespace and adds a convenient
scrollbar if the content is too wide. If inside an
inflatable nested grid, it
will have negative margin to make its contents aligned with surrounding text.
Footnotes and footnote references
Applying .m-footnote
to a link will turn it into a footnote reference
— a superscript, wrapped in brackets. For the actual footnotes use
<dl class="m-footnote">
; <dt>
contains footnote ID and
<dd>
the footnote text. You can add a <span class="m-footnote">
inside the <dd>
to provide styled back-references to the original text.
Text alignment and wrapping
Use .m-text-left
, .m-text-right
or .m-text-center
to
align text inside its parent element. Use .m-text-top
,
.m-text-middle
and .m-text-bottom
to align text vertically for
example in a table cell. See Floating around
in the grid system for aligning and floating blocks in a similar way.
By default, all text is wrapped according to default HTML rules. In order to
look better on very narrow screens, it’s possible to use ­
to
hyphenate words. The <wbr/>
HTML tag does the same without rendering
any hyphens, and finally there’s a .m-link-wrap
you can apply to links
with long URLs to break anywhere. Both hyphenation and link wrapping can be
done either manually on a case-by-case basis, or using the
m.htmlsanity plugin, which can do both
automatically.
Inline elements
Links are underlined by default in all builtin themes.
Adding .m-flat
to the <a>
element will remove the underline,
useful where underlines would be too distracting:
For cases where you can’t use the native HTML tags for emphasis, strong text,
strikethrough and subscript/superscript, the equivalent is available through
.m-em
, .m-strong
, .m-s
, .m-sup
and .m-sub
CSS classes used together with .m-text
.
Padding
Block elements <p>
, <ol>
, <ul>
, <dl>
,
<blockqote>
, <pre>
and <hr>
by default have 1rem
padding on the bottom, except when they are the last child, to avoid excessive
spacing. A special case is lists — components directly inside <li>
elements have 1rem
padding on the bottom, except when the <li>
is last, to achieve consistent spacing for inflated lists.
The 1rem
padding on the bottom can be disabled with .m-nopadb
,
similarly as with grid layouts. On
the other hand, if you want to preserve it, add an empty <div></div>
element after.