最近、ユーザーからWordPressで改行を追加したり、ブロック間の行間を調整する方法はないかと尋ねられました。
たいていのワープロでは、Enterキーを数回押すだけで、簡単に空白行を追加することができます。また、設定オプションから段落の後にダブルスペース行を作成することもできます。しかし、WordPressのブロックエディターにはそのようなボタンはありません。
この投稿では、WordPressで簡単に改行を追加する方法を紹介します。
始める前に、行間は使用しているWordPressテーマによってコントロールされることを知っておくことが重要です。
ブロックエディターでブロック間にスペースを追加する方法を紹介し、その結果に満足できない場合は、テーマの行間を変更する方法を説明します。
動画チュートリアル
動画が気に入らなかったり、もっと説明が必要な場合は、このまま読み進めてください。
ブロック間に二重線スペースを追加する
Windowsの場合はEnterキー、Macの場合はReturnキーを押して改行すると、WordPressはそれを新しい段落とみなします。
これは、あなたのテーマがそのためのスタイルを持っている(すべての良いWordPressテーマがそうである)限り、自動的にダブル行スペースを追加することを意味します。
コンテンツエディターに移動し、行の後にEnterキーまたはReturnキーを押し、次の行に別の何かを入力するだけです。
そうするだけで、テーマのスタイリングに基づき、段落間の区別が明確になるはずだ。
個別行スペースの追加
さて、住所のようなものを書く場合、WordPressサイトではダブルスペースではなく、個別スペースにしたいだろう。
この場合、WindowsではSHIFT + ENTERキー、MacではSHIFT + RETURNキーを押す必要があります。
これはWordPressに、既存の段落の中で改行したいことを伝えます。したがって、個別行間と二重行間が必要になります。
線の高さと間隔の変更
エディターで適切な行間を追加しても、テーマでは思い通りに表示されないことがある。
解決する方法は2つある:
- プラグインを使う(簡単な方法)
- 手動によるCSSコード(より高度なもの)
まずは簡単な方法を見てみよう。
プラグインを使って行間を追加する
コードを学ぶことなくテーマにスタイルの変更を加えたい場合は、CSS Heroのようなプラグインを使うのが一番です。
CSS Heroを使えば、コードを知らなくてもWordPressサイトのデザインを簡単に変更できます。
詳しくはCSSヒーローのレビューをご覧ください。
サイドバーの移動やフッターの追加など、テーマに大きな変更を加えたい場合は、ドラッグ&ドロップのページビルダー・プラグインの方が良い設定だろう。ページビルダー・プラグインを使えば、WordPressでフォントの色を変えたり、改行を追加したりといった小さな調整もできる。
プラグインを使いたくない、あるいは、たったこれだけの変更が必要だとお考えですか?それなら、手動CSSコード設定が最適かもしれません。
CSSコードで段落間隔を手動で変更する
プラグインを使わずに手動で改行を追加するには、テーマにCSSを追加する必要がある。
CSSは基本的に、Microsoft Wordの書式設定機能のようなものです。ボタンをクリックする代わりに、プレーンなCSSコードを書くことになる。初心者が思っているほど怖いものではありません。指示に従うだけなら、CSSはとても簡単に理解できます。
テーマにカスタムCSSを追加するには、外観 ” カスタマイズページにアクセスする必要があります。WordPressテーマカスタマイザーが起動しますので、左の列から「Additional CSS」タブをクリックしてください。
これらのメニューオプションが表示されない場合は、ブロックテーマを使用している可能性があります。WordPress管理画面のテーマカスタマイザーが表示されない場合の対処方法の投稿をご覧ください。
カスタムCSSボックスに、以下のCSSコードを追加する必要があります:
.post p{line-height: 1.5em;}
上に示したCSSルールは、段落コンテンツの行間を1.5emに変更します。emはタイポグラフィの幅の単位です。
.post
クラスを使用していますが、これはWordPressがすべての投稿のコンテンツエリアに自動的に追加するもので、投稿だけに影響し、他の場所で使用されている段落には影響しません。
さて、これは個別スペーシングの間隔を変えるだけである。
WordPressで段落の間隔を変えたい(つまりダブルスペースにしたい)場合は、パディングを追加する必要がある。
.post p {
line-height: 1.5em;
padding-bottom: 15px;
}
ご自由に数字を調整し、HTMLでダブルスペースを追加してください。
また、WPCodeプラグインを使用してサイトにカスタマイザーCSSを追加することができます。このプラグインを使えば、サイトへのコードの挿入や管理がとても簡単になります。
詳しくは、WordPressサイトにカスタムCSSを追加する方法をご覧ください。
この投稿がWordPressで改行を追加するのにお役に立てば幸いです。WordPressのブロックパターンの使い方や、GutenbergにフレンドリーなWordPressテーマも参考にしてみてください。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
phil rooksby
I don’t have Additional CSS. I’ve tried all sorts of other ways to alter the paragraph spacing but nothing works, looks a real mess. Help please!!!
Norm
Thank you for the help. I have been looking all over the place, and wanted to do it with a plug-in. You made it so easy. Again, thank you very much.
Maria
Hello! I want to have a simple spacing between my paragraphs and even after pressing enter (for the double space), when I preview the draft nothing has changed (it’s still all one paragraph). Could anyone help?
Rashmi
Hi
I would like to modifying the Line height and Spacing. However there is no ‘editor’ icon ( Appearance » Editor) from theme’s CSS file.
So, what can I do?
Thank you for your reply!
Hannah
Wow. Didn’t know it was so easy. Thank you so much! This double space was driving me crazy!
Christine
Thank you! So much easier!
Donna
Thank you, thank you, thank you!
I was in another html editor and could not figure out how to do single spacing.
You saved the day!
Gerard
Brilliant and what an eternal lifesaver.
I was struggling with spacing on one of my client sites and absolutely amazing that you had the exact answer almost at your finger tips. I am now becoming a permanent subscriber
Elandre
Thanks for all the Wordpress tips. This site has helped me a lot with most struggles I had
LR
I am using the Pilcrow theme and I have no idea how to make the double space between paragraphs happen. Sometimes it happens in my posts but sometimes it doesn’t. When I look in the HTML file I don’t see any post p or padding. I only see the end result of what the post will look like and thats when I know the double spacing didnt work. Can I still go back and re-edit and fix it? Last but not least where you say to go from the appearance to editor menus i dont have those options.
I have under appearance the following options: themes, customize, widgets, menus, header, background, AMP, Theme Options, Mobile.
Please help.
WPBeginner Support
Hey LR,
You can add the CSS by visting Appearance->Customize and then clicking on the Additional CSS tab in customizer. See our guide on how to add custom CSS in WordPress.
If you believe it to be a theme issue, then try temporarily switching to a default WordPress theme. If the issue disappears, then you can ask your theme developer for support.
管理者
Derek Cummings
My theme is broken, as in it doesn’t have the double spacing by default. The theme is stuck on the shift+enter mode in other words. So in relation to the following code:
.post p {
line-height: 1.5em;
padding-bottom: 15px;
}
Is 15px a normal default double space? How many pixels should it be by default? Also doesn’t it matter where I put this code? Thanx!
Femi
Thank you for the tip on the shift + enter. I never knew this for years. Your site has always been a rescue when I get stuck.
Lyn
Hello: How do you get custom line spacing (say, 1.5em) for one instance on one page instead of changing the entire theme CSS? I see two other people have asked the same thing with no response, at least not that I found. Thanks!
Denise B
I set the p margins to zero. In your CSS, it would be something like p {margins: 0; }
Los Hundlos
Shift+Enter to avoid huge gap between lines in wysywig tinye mce editor in wordpress. Works !!!! Awesome!
Cat
How about simply adding some text and changing the text colour to white (if the background is white)? This should make it possible to create and customise line spaces much easier (unless, of course, the background is a picture of something that cannot be matched with font colour).
Tim
Thanks so much! Life saver!
Michael Rich
Hi WPBeginner staff,
I have a different question. I use Visual Composer and have added many Separator with Text dividers between my section headings on my homepage. I would like to make those text headings also be a link to that section.
However everytime I add the link I lose the section identifying text that I had in the separator and it’s magically replaced with the default text saying “TITLE”.
To try to make it a link I am adding a the linking code inside this bracket:
[vc_text_separator title=”1950s CARS”]
I am scratching my head so hard that I think I’m bald. Any help will get you a lifetime of gratitude!!!
Thankyou,
Mike
Anthony Cooper
I am using the WordPress ‘Divi’ theme and found that if you press enter (or shift + enter) twice, in order to create a larger space, it is ignored. To get round this press enter once, type a character on the line, (it does not matter what), highlight it and change the font colour of the character to white and then press enter again; this results in the desired space between lines without having to edit the theme. The same applies to extra spaces in a line; enter as many characters as desired, highlight them and change their font colour to white and then carry on in the desired font colour.
Julie
Brilliant tip! Thanks so much for this, you saved me from lots of headaches and hassle Anthony!
Robin Brinkler
Remember that some search engines could treat “hidden” text like this as spam.
Ellen
This was really helpful, thanks!
Christy
THANK YOU!! I Love you guys! So glad I found this site! I’ve almost literally been banging my head against the wall. If I knew how to insert emojis, this post would be covered with hearts and smiley faces.
Christy
P.S. ~ HA! I did NOT know that my little colon and parentheses would actually turn into a smiley. LOL
Linda Paul
Oh yeah! You have just helped me solve a problem (forced single space paragraphs) that has vexed me for years!
WPBeginner Support
Glad you found it helpful
管理者
David M. Ebersole Sr.
I am a subscriber to WP Beginner.
I had a question concerning entering Engineering data for my product on my site. Spacing in the tables appeared too large on the page. I searched Wordpress support and all I saw was snippy responses to the question of single line spacing.
Your the first to answer the question, and it obviously was correct. Thank You.
Sincerely,
Dave
WPBeginner Support
Glad you found it helpful
管理者
Mark
What about on Android. The latest update has forced a double spacing (new paragraph). Not very good for poetry writers. Is there any way to revert it back to single?
Cheryl
I use Omega Theme and the control/enter does not work. Is there something else I can do. I cannot find post.p in the CSS file.
Becky
Very helpful, thank you!
Adnan Khan
Thanks, this most useful Tip for new wp user
Tina Gleisner
Thanks for the “shift” and enter for single line spacing as I’ve wanted to figure this out for years … and never got around to finding the solution.
Ian
Hi,
This worked for me but the CSS doesn’t do anything in my page…
Will
Same thing happened to me. Is there an updated code to insert?
A. Lougheed
I’m searching everywhere for an answer … when I add a in the text editor, it is removed in the visual editor. Drives me crazy. Does wpbeginner have a recommendation?
Should I add a plug-in to stop this?
I tried a plugin years ago, but I had to go back and re-format every post.
Any link with tutorial or advice is greatly appreciated!
WPBeginner Support
Actually it is also removed from your comment.
Please see our guide on How to add special characters in WordPress posts.
管理者
Jessica
Whats the code for adjusting line height for one single post?
Bharadwaj
Thank you, Helpful
Samadarshi
Thank you for such wonderful articles
I was completely lost when I started wordpress but now I have a pretty basic idea
Thank u
Neal Umphred
Thanks! This helped me tighten up my posts—except for the first paragraph in each post. For some reason, the lines appear to be double-spaced. Is there a snippet of code that I could add to Edit CSS that would allow me to tighten them?
Neal Umphred
Thanks! Adding the snippet (.post p{line-height: 1.5em;}) to my Edit CSS made my text so much easier to read. Now, here’s my problem: the opening paragraph in each WordPress post has much larger line spacing than the rest of the paragraphs—and it is NOT affected by this piece of line-height code. Is there another snippet of code that I could add to Edit CSS that would tighten up those opening lines?
tiffany
Thank you so much. Your site is remarkable. It has helped me so much. Subscribed!! Please keep up the great work!!
WPBeginner Support
Thanks for the kind words. We are glad to help.
管理者
Joe Simmons
Thank you! I didn’t know about the “shift+enter” thing either.
Debby
Shift + Enter. Who knew it was that simple! Thank you, thank you, thank you!
Gamo Nana
thanks for the single line spacing with SHIFT + Enter
Bob M.
I’d like to thank you for this bit of wisdom (Shift+Enter) too!
JE
Thanks for the tutorial. Although, how can I adjust single paragraph line spacing? I have a 3 word title, centered and stacked in 3 lines. All of the lines have different font size, so the line spacings are inconsistent. I’ve been looking for a way to easily adjust through a text editor tool or plugin.
Any ideas?
Syed Balkhi
We just used a browser search box which you can find by pressing Ctrl + F
Mx
Finding .post p you used a search box. Will you tell me how to find that search box? Thanx4
Jun Han
This is very helpful.
Thanks.
http://www.digitalgrog.com.au/
it was my pet peeve until now ..thanks now i can space properly ..btw i made a list of hosts check itout
http://www.digitalgrog.com.au/australian/comparison-on-blog-web-hosting-for-australians/
Karen Surfy Mum
Awesome!! I also have wanting to find out how to do this for ages!!! So simple when you know… cheers xxx
Widdershins
Oiiiiiiiiiiii!!! I’ve been trying to find out how to do that for yonks!!!!
Thankyouthankyouthankyou
fastow2012
“If you do not find the .post p tag, then simply create one.”
Where? should i just copy/paste it anywhere in the css file?
WPBeginner Staff
preferably at the bottom of the css file.
Mx
Sorry, but I still dont get where to place it. Is is possible to explain it more detailed? Thanx
James
I’ve always wondered how to do this. Thanks for the training.
Valerie
I’m not even a true “beginner” but there are gaps in my knowledge and you have just solved one of the most frustrating things about WP for this writer and Word user… Thank you for this and for all your fantastic info… I continue to learn great things from your posts and your site. Thanks and cheers to you!
kelly
almost four years of blogging and finally! so awesome, thanks!!