As a long-time coder well-versed in various markup languages, I often extoll the virtues of markdown for writing project docs, technical tutorials, work logs, and more. Markdown balances simplicity with flexibility – allowing some text formatting without drowning writers in dense syntax.

However, adjustting text size does not come built-into markdown‘s minimal feature set. Still, with some creative use of HTML tags, we can gain control over fonts. Specifically, the <font> tag opens possibilities to emphasize text through sizing.

In this comprehensive guide, we will cover how markdown handles fonts, smart practices for presenting sized text in multiple use cases, and custom solutions pushing markdown‘s capabilities further. Read on to make your docs, blogs, and readme files easier on the eyes!

Understanding Font Size Fundamentals

Before diving into code, we should ground ourselves in some font size basics.

Typically, the final display font for a web document depends on:

  • Default font specified in the stylesheet CSS
  • Font styling tags included in the HTML or markdown
  • Reader‘s browser and text zoom settings

By adding <font> tags in markdown, we override the default size. This causes the contained text to render bigger or smaller, regardless of user settings.

Here is an example font size change on some text:

Here is some normal text and <font size="4">some larger text</font> reverted to normal.

Renders as:

Bigger font size example

The number passed to size correlates with standard HTML font sizes from 1 to 7. Though not exact pixel values, higher numbers increase rendering size.

Font sizes map to relative sizes as follows:

Size Attribute Value Relative Size Example Description
1 0.6em Very small
2 0.8em Small
3 1.0em Normal/base size
4 1.2em Medium/Large
5 1.5em Big
6-7 2.0em Extra big

Setting text size this way overrides inherited CSS or consumer settings to force specific sizing. Next we will explore smart use cases taking advantage of this functionality.

Smart Practices for Markdown Font Sizes

Though we can slap font tags arbitrarily around markdown documents, more thoughtfully choosing size changes improves reader experience. Let‘s examine some best practices for presenting sized text.

1. Emphasize Importance in Tutorial Content

Online coding and tech tutorials often utilize markdown for clean documentation and distribution. When learning new concepts, calling attention to key terms, warnings, or code snippets through sizing improves comprehension and retention.

Let‘s see an example from a JavaScript tutorial:

# Building a Simple JavaScript Game 

Welcome to the first tutorial in our JavaScript for Beginners series! 

Today we will build a basic math game to introduce core programming concepts like **variables**, **functions**, **loops** and **conditionals**. So let‘s get started!

First we initialize our **<font size="5">gameEngine</font>** module:

```js
// Game engine initialization
initGame(); 

function initGame() {
  // Game code  
}
```

The **<font size="5">initGame()</font>** function will hold all our main game logic. More on that soon!

In this snippet, key ideas stand out through selective font sizing while keeping surrounding body text easier to scan read through consistent default sizes. This builds appropriate visual hierarchy focused on key learning points.

Code tutorial with enlarged fonts

2. Maintain Text Hierarchy in Reports

Sizing also helps develop proportionate, readable text hierarchy in complex markdown documents like data analysis reports, whitepapers, and multi-chapter ebooks exported from writing tools like Scrivener.

Here is an excerpt from an annual sales report:

2020 Northeast Region Sales Report

This report summarizes Northeast sales figures for the 2020 calendar year, analyzing trends across customer segments compared to projections. Several sales targets were missed this cycle, seemingly impacted by broader economic shifts.

Economic Factors

Consumer spending suffered under high localized unemployment rates through Q3 2020. Food services took the biggest hit (15% losses YoY) while budget general merchandise stores saw mild gains as shoppers focused on essentials and value due to:

  • Pandemic restrictions closing restaurants and limiting services spending

  • Double digit unemployment spiking to over 20% of local workforce

Recommend calibrating future projections by lowering targets (8-12% down) and timelines through 2021 while economy stabilizes. Focus holiday sales initiatives on discounted necessity goods.



Appropriately decreasing from report title to top-level headings to body text establishes reader flow. Sizing subjectively seems to fit the relative importance of each section. Sticking with defaults for data lists also keeps numbers highly scannable.

### 3. Review and Revise Long Form Documents 

Consistent markdown drafting in a writing tool allows exporting clean content with minimal effort thanks to markdown‘s seamless workflow across apps. 

Unfortunately any custom text formatting often disappears. Reintroduce font changes during editing passes to reestablish text hierarchy for final distribution formats like PDF ebooks or website publishing.

> **Tip:** Use editor search to mass identify headings, bold text etc then size appropriately with find-and-replace. I like Visual Studio Code for handling large markdown docs.

 ### 4. Mind Accessibility Needs

Font size changes introduce issues like inducing zoom behavior on mobile screens or overriding vision impairment reader settings. Set sizes judiciously with enough difference to add emphasis yet keep incremental for easier overrides. 

Also consider maximal limits since extra large fonts for long stretches negatively impact overall UX, especially for readers with attention deficit disorders. Site stylesheets ultimately govern proportional text for a reason!

Now that we‘ve covered smart sizing practices, let‘s tackle working around font size limitations in markdown.

## Pushing Past Limits with Custom Solutions

The simplicity that makes markdown great also introduces capability gaps that may frustrate power users. What if we need more sizes than 1 through 7? Or relative scaling? Various tooling extends markdown for advanced font control.

### Use MultiMarkdown Custom Sizing

[MultiMarkdown](https://fletcher.github.io/MultiMarkdown-6/) builds on standard markdown syntax with additional features like [custom HTML class tags](https://fletcher.github.io/MultiMarkdown-6/custom_class_names.html) for fine-tuned styling hooks. 

For flexible font sizing, we can define a custom tag tied to specific CSS:


```
CustomFontSizes {  
  .font8 {
    font-size: 2.5em 
  }

  .font10 {
    font-size: 3em
  }
}  
```

Now text marked up like `<span class="font8">Bigger text</span>` will output that size! Endless custom variants now become available.

This requires running content through a MultiMarkdown parser vs standard markdown though.

### Develop a Custom Plugin

For more control without a proprietary toolchain, develop a custom markdown plugin leveraging the syntax tree available through libraries like [markdown-it](https://github.com/markdown-it/markdown-it).

Say we want any text wrapped in `~` tildes to scale 1.5x the base size. Our plugin just needs to handle that tag, measure relative sizing, then wrap an appropriate `<font>` tag around that node of the document syntax tree during render. 

Voila - custom shorthand without changing fundamental markdown authoring!

### Build Stylesheet Overrides

Take control completely by overriding base stylesheet sizing at the HTML render level:


```css
/* Default paragraph text */
p {
   font-size: 1.1em; 
}

/* Override with custom class */
p.giant {
   font-size: 3em !important;
} 
``` 

Now markdown like:

```
<p>Normal text</p>

<p class="giant">Very large text!</p> 
```

Gives total control while keeping authoring clean and simple in markdown files themselves.

## Conquering Cross-Browser Consistency 

Perhaps the biggest challenge with font tags is achieving pixel-perfect consistency since default sizing and even system fonts vary across devices and browsers.

Always preview markdown renders in multiple environments during drafting. I recommend a mix of:

- Locally via CLI markdown processor like [Marked](https://marked.js.org) 
- VSCode/Atom built-in previews
- Hosted sandbox renderers like [Dillinger.io](https://dillinger.io/)
- Browser testing on physical devices 

Normalize as much as possible upfront through CSS resets targeting at least heading tags. 

Ultimately pentesting text across environments gives the cleanest picture of how sizing will hold up. Replace custom fonts with standard web safe stacks and always validate responsiveness in mobile.

## Readability Research for Font Size Optimization

We have covered several ways to override default markdown text sizing. But how large should fonts be for optimal comprehension? Too small and readability suffers. Too large and we sacrifice information density causing additional scrolling fatigue.

Various typography studies identify ideal relative sizes for long form reading:


| Document Part               | Recommended Font Size | Example    | 
|-----------------------------|-----------------------|-------------|
| Title                       | 32px                  | Post title  |   
| Headings                    | 24px                  | H1, H2      |
| Body                        | 16px                  | Paragraphs  |
| Figures/Captions/References | 12-14px               | Image text  |


Of course user testing across reader demographics and contexts provides additional insights to tune as needed. But in general we can apply the same proportion concepts covered in our font size best practices through markdown sizing. Stick to 2-3 relative sizes in a document avoiding more than a 2 level font size jump between adjacent elements.

Here is a sample report structure demonstrating stylized text hierarchy through sizes 6 and 4:

**<font size="6">Quarterly Sales Report Q1 2019</font>**

## Executive Summary

<font size="4">Regional revenue was 20% above projections primarily driven by the Direct Consumer division‘s digital marketing campaigns and expansion into secondary markets.</font> Food services faced challenging headwinds this quarter from local minimum wage hikes increasing labor costs.

While the 32px ideal suits headings, numbers would be too large. So the concept encourages customization as needed.

## The Bottom Line

This deep dive covered how to take control over text size in markdown documents. We explored:  

- **Inlining `<font>` tags** - Simple yet manual approach to override default document styling
- **Custom extensions** - MultiMarkdown and plugins expanding markdown syntax for advanced sizes  
- **External styling** - Custom CSS and stylesheet overrides to control sizes programmatically
- **Cross-environment testing** - Validate appearance across browsers and devices through pentests
- **Readability research** - Typographic studies offer data-backed ideals for long form sizing

With a few font tag tweaks, your markdown content can better highlight key points for readers through visual hierarchy and appropriately sized textual emphasis. So tweak fonts keeping consistent baseline composition intact. Your docs and writing will benefit in clarity and engagement through properly sized text.

Similar Posts