How to Create Beautiful Article Separator Styles
Effect Demonstration
The Not yet implemented
in the image above is a concise and aesthetically pleasing separator, and the text content can be customized.
How it works like:
Implementation Method
Using CSS to beautify the comment text following the separator and simulate a symmetrical separator (the bottom line is actually imitated using border-bottom
).
First, write it in this format:
___
%% Separator Text %%
Then apply this CSS:
🎨 CSS Code
Download the newest css: Beautified separator style for Obsidian
Or just copy this:
/* Moy OB Basic Style Adjustments */
/* Created: 2025-04-03 */
/* Make comment text smaller */
.cm-comment {
font-size: 0.8em;
opacity: 0.8;
}
/* Beautified separator style */
/* ! Comment after the underline */
/* Real-time editing mode */
.hr + .cm-line:has(.cm-comment) {
text-align: center;
padding-top: 0px !important;
.cm-formatting {
opacity: 0.0;
}
padding-bottom: 0.6em;
border-bottom: 2px solid var(--hr-color);
opacity: 1.0;
}
.hr + .cm-line.cm-active:has(.cm-comment) {
.cm-formatting {
opacity: 0.8;
}
}
/* Source code mode, only center text and add underline */
.HyperMD-hr + .cm-comment {
text-align: center;
border-bottom: 2px solid var(--hr-color);
}
/* This version uses *emphesis text* after the underline - it could be used in reading view! */
/* Live Editing */
.hr + .cm-line:has(.cm-em) {
text-align: center;
padding-top: 0px !important;
padding-bottom: 0.6em;
border-bottom: 2px solid var(--hr-color);
opacity: 1.0;
.cm-em {
opacity: 0.6;
}
}
/* Source Mode */
.HyperMD-hr + .cm-line:has(.cm-em) {
text-align: center;
border-bottom: 2px solid var(--hr-color);
}
/* Reading Mode */
.el-hr + .el-p:has(em) {
text-align: center;
padding-top: 0px !important;
p {
margin-top: 0em;
opacity: 0.8;
margin-bottom: 0em;
}
margin-top: -1.5em;
margin-bottom: 0em;
padding-bottom: 0.4em;
border-bottom: 2px solid var(--hr-color);
opacity: 1.0;
}
Note: Only effective in editing mode, as comment text is not rendered in reading mode.
Tips: Using Underscore as Separator Symbol
It is recommended to use the underscore ___
instead of the dash/minus ---
as the separator symbol.
Because ---
itself is also used as the “title” syntax in Markdown format, and if there is no blank line before it when typing, it will turn the preceding text into a title, resulting in a poor experience.
<!--Will be treated as a title-->
This is text
---
<!--Normal use as a separator-->
This is text
___
For reading mode
Since the reading mode doesn’t render the comment, so I also added a em
version:
Like this:
___
*Text*
The benefit is that it can be rendered in all three view modes.
Choose whatever you like :3