Skip to content

Commit 2fc854a

Browse files
committed
add md for Line Spacing and Paragraph Spacing
1 parent f2a9b67 commit 2fc854a

File tree

4 files changed

+224
-1
lines changed

4 files changed

+224
-1
lines changed

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TypeWiki
2+
3+
This is the source code for Typora's support wiki (Markdown editor). The site is published at https://support.typora.io.

_posts/how-to/2016-06-25-Add Custom CSS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ You can open Chrome/Safari DevTools to debug element styles.
5555

5656
- [Font](/Custom-Font/)
5757
- [Typeset](/Typeset/)
58+
- [Line Spacing and Paragraph Spacing](/Line-Spacing/)
5859
- [Background](/Backgound/)
5960
- [Code Blocks](/Code-Block-Styles/)
6061
- [Headers](/Auto-Numbering/)
61-
- [Width od Writing Area](/Width-of-Writing-Area/)
62+
- [Width of Writing Area](/Width-of-Writing-Area/)
6263
- [List Styles](/List-Style/)
6364
- [Task List](/Task-List/)
6465
- [Text Direction](/RTL/) (RTL)

_posts/how-to/2021-03-20-Typeset.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ You can change [font ligatures](https://developer.mozilla.org/en-US/docs/Glossar
9696

9797
## Paragraph & Alignment
9898

99+
#### Line Spacing and Paragraph Spacing
100+
101+
To change line spacing (space between lines) and paragraph spacing (gap between paragraphs), see </Line-Spacing/>.
102+
99103
#### Justify Alignment
100104

101105
```css
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
---
2+
layout: post
3+
title: Line Spacing and Paragraph Spacing
4+
author: typora.io
5+
category: how-to
6+
tags:
7+
- style
8+
- CSS
9+
typora-root-url: ../../
10+
---
11+
12+
Typora uses CSS to control spacing. You can customize **line spacing** (the space between lines within a paragraph) and **paragraph spacing** (the gap between paragraphs) by adding [Custom CSS](/Add-Custom-CSS/).
13+
14+
**Outline**
15+
16+
* Outline
17+
{:toc}
18+
19+
## Quick Start
20+
21+
If you just want tighter spacing to see more content on screen, add the following to your `base.user.css` file (see [how to open it](/Add-Custom-CSS/)):
22+
23+
```css
24+
#write {
25+
line-height: 1.2;
26+
}
27+
28+
#write p,
29+
#write li {
30+
margin-top: 0.25rem;
31+
margin-bottom: 0.25rem;
32+
}
33+
```
34+
35+
This gives you compact single-like spacing with minimal gaps between paragraphs. Adjust the values to your preference.
36+
37+
## Line Spacing
38+
39+
Line spacing is controlled by the CSS `line-height` property. Different themes set different defaults — for example, the GitHub theme uses `1.6`, while others may use `1.4` or `1.5`.
40+
41+
To change line spacing for the entire writing area:
42+
43+
```css
44+
#write {
45+
line-height: 1.6; /* default for GitHub theme */
46+
}
47+
```
48+
49+
Common values:
50+
51+
| Value | Effect |
52+
|-------|--------|
53+
| `1.0` | No extra space between lines (very tight) |
54+
| `1.2` | Tight, compact spacing |
55+
| `1.4``1.6` | Comfortable reading (most theme defaults) |
56+
| `1.8``2.0` | Double-spaced, similar to Word's "double" |
57+
58+
You can also use other CSS units:
59+
60+
```css
61+
#write {
62+
line-height: 24px; /* fixed pixel value */
63+
line-height: 1.5rem; /* relative to root font size */
64+
line-height: 1.5em; /* relative to element font size */
65+
line-height: 1.5; /* unitless — recommended, scales with font size */
66+
}
67+
```
68+
69+
> **Tip:** Unitless values (like `1.5`) are generally recommended over fixed units, because they scale proportionally when you change font size.
70+
71+
### Line Spacing for Specific Elements
72+
73+
You can set different line spacing for headings, paragraphs, or other elements:
74+
75+
```css
76+
/* tighter headings */
77+
h1, h2, h3, h4, h5, h6 {
78+
line-height: 1.2;
79+
}
80+
81+
/* more space in paragraphs */
82+
#write p {
83+
line-height: 1.8;
84+
}
85+
86+
/* compact lists */
87+
#write li {
88+
line-height: 1.3;
89+
}
90+
91+
/* code blocks */
92+
.md-fences {
93+
line-height: 1.4;
94+
}
95+
```
96+
97+
## Paragraph Spacing
98+
99+
Paragraph spacing is controlled by CSS `margin` properties. By default, Typora adds `1rem` of margin above and below each paragraph.
100+
101+
To reduce the gap between paragraphs:
102+
103+
```css
104+
#write p {
105+
margin-top: 0.25rem;
106+
margin-bottom: 0.25rem;
107+
}
108+
```
109+
110+
To remove paragraph gaps entirely:
111+
112+
```css
113+
#write p {
114+
margin-top: 0;
115+
margin-bottom: 0;
116+
}
117+
```
118+
119+
To increase paragraph spacing:
120+
121+
```css
122+
#write p {
123+
margin-top: 1.5rem;
124+
margin-bottom: 1.5rem;
125+
}
126+
```
127+
128+
### Spacing for Other Block Elements
129+
130+
Paragraphs are not the only elements with spacing. You can adjust headings, lists, blockquotes, and code blocks too:
131+
132+
```css
133+
/* heading spacing */
134+
h1, h2, h3, h4, h5, h6 {
135+
margin-top: 1.5rem;
136+
margin-bottom: 0.5rem;
137+
}
138+
139+
/* list item spacing */
140+
#write li {
141+
margin-top: 0.15rem;
142+
margin-bottom: 0.15rem;
143+
}
144+
145+
/* blockquote spacing */
146+
blockquote {
147+
margin-top: 0.5rem;
148+
margin-bottom: 0.5rem;
149+
}
150+
151+
/* code block spacing */
152+
.md-fences {
153+
margin-top: 0.5rem;
154+
margin-bottom: 0.5rem;
155+
}
156+
```
157+
158+
## Full Example: Compact Layout
159+
160+
Here is a complete example for a compact, single-spaced layout that maximizes visible content:
161+
162+
```css
163+
/* compact line spacing */
164+
#write {
165+
line-height: 1.3;
166+
}
167+
168+
/* minimal paragraph gaps */
169+
#write p,
170+
#write li {
171+
margin-top: 0.2rem;
172+
margin-bottom: 0.2rem;
173+
}
174+
175+
/* tighter headings */
176+
h1, h2, h3, h4, h5, h6 {
177+
line-height: 1.2;
178+
margin-top: 1rem;
179+
margin-bottom: 0.3rem;
180+
}
181+
182+
/* compact blockquotes and code blocks */
183+
blockquote,
184+
.md-fences {
185+
margin-top: 0.4rem;
186+
margin-bottom: 0.4rem;
187+
}
188+
```
189+
190+
## Full Example: Relaxed Layout
191+
192+
For a more spacious, double-spaced feel:
193+
194+
```css
195+
#write {
196+
line-height: 2.0;
197+
}
198+
199+
#write p {
200+
margin-top: 1rem;
201+
margin-bottom: 1rem;
202+
}
203+
204+
h1, h2, h3, h4, h5, h6 {
205+
margin-top: 2rem;
206+
margin-bottom: 1rem;
207+
}
208+
```
209+
210+
## Related
211+
212+
- [Add Custom CSS](/Add-Custom-CSS/) — where to place your CSS
213+
- [Custom Font](/Custom-Font/) — change font family and size
214+
- [Width of Writing Area](/Width-of-Writing-Area/) — adjust page width
215+
- [Typesetting with CSS](/Typeset/) — more typesetting options

0 commit comments

Comments
 (0)