The idea behind Cured HTML is to remove the need for manually tagging paragraphs through judicious use of CSS rules. The result is a format that looks like simple text when you write simple text, but has all the capabilities of HTML when those are necessary.
Here is the general recipe:
And here is how the markup looks like:
- Designate a tag or a class as container for handwritten HTML.
- Set its
white-space CSS property to keep track of newlines, but collapse consecutive whitespace.
- Reset margins and padding of all nested elements to 0.
- Create individual CSS rules for semantic text elements (headers, blockquotes, lists, etc.) so that reasonably formatted text is rendered as reasonably looking page content.
<h1>A top headind</h1>
This is the first paragraph.
This is the second paragraph. You can use <i>inline</i> tags with no issues.
This is a blockquote.
Hopefully you get the picture.
Let's start with the main two CSS rules:
cured will be applied to the tag containing handwritten HTML. These rules effetively implement the first three steps from the recipe above.
Next, single-line block elements (that will reside on the same line as their surrounding tags) will have to be made either inline or inline-blocks. You don't want them to be full blocks, because preceding and following newlines in text will by themselves take care of spacing.
Finally, multi-line blocks (ones where opening and closing tags are on their own lines) will unfortunately need some CSS hackery:
--negative-line-height: calc(-1 * var(--line-height));
background-color: hsl(40, 50%, 90%);
box-shadow: inset 0 var(--line-height) var(--text-background);
The problem is that the very first newline after the opening tag of our blockquote will introduce an empty line at the top of blockquote's rendered box. In Chrome and in quirks mode Firefox it can be elegantly fixed by styling pseudo-element
line-height of 0. Unfortunately, this does not work in Firefox standards mode.
Instead, we "bleach" the top portion of the box via box-shadow. To make sure it all aligns properly, we use CSS variables tied to line height. Not a great solution, but passable.
You might wonder why not just make block quotes a full-width inline block. It's an option, but one that intereferes with many CSS properties that you might find convenient when formatting a low-markup document (like auto margins).
It's possible to make a self-contained version of the CSS involved, but a lot of those rules would be superceded by a CSS reset, so the practical worth of a self-contained version is questionable. The important thing is to understand the overall approach and know useful CSS rules at your disposal.