Read More Without JavaScript
Two ways to collapse long text with HTML and CSS only: a native <details> element, and a three-line preview with line-clamp. Every word stays in the HTML — and we clear up what “hidden content” really means for SEO.
- JavaScript
- 0 KB
- Built with
<details>,line-clamp,:checked- Browsers
- All current browsers (Chrome, Edge, Firefox, Safari)
- Updated
No. Put the extra text in a <details> element and use its <summary> as the “Read more” button — the browser handles the rest. For a preview that cuts the text after a few lines, use line-clamp and a checkbox. Either way the full text is in the HTML, so search engines index all of it.
Live demo: two kinds of “Read more”
On the left, the extra paragraphs sit in a <details> element. On the right, one long paragraph is cut after three lines. Both texts are real — practical advice for websites in China, with links to our checklist and tools.
With <details> — recommended
Building a website for visitors in mainland China? Three technical decisions matter long before any SEO work starts: where the site is hosted, which fonts it loads, and which third-party scripts it depends on.
Read more Show less
Hosting. A server outside China can be slow or unreliable for Chinese visitors. Hosting inside mainland China requires an ICP filing for the domain.
Fonts. Google Fonts is not reliably reachable from mainland China. System fonts such as PingFang SC and Microsoft YaHei load instantly.
Scripts. Google Maps, reCAPTCHA and YouTube embeds don't work in mainland China — and if a page waits for them, it may not load at all.
Preview with line-clamp
A complete Chinese web font contains well over 20,000 characters and often weighs several megabytes — far too much for a fast page, especially on mobile networks. But a typical website uses only a few thousand different characters. Font subsetting keeps exactly those and drops the rest, which turns a multi-megabyte file into a few hundred kilobytes. Paste your site's text into our free subset generator and it lists the characters, gives you the commands to cut the font, and writes the @font-face CSS — including a fallback for characters you add later.
How the two versions work
<details>: the browser does it allThe
<summary>is a real button: focusable, opened with Enter or Space, announced as expanded or collapsed. The intro paragraph sits outside, so it is always visible.- Button text as real text
Both labels — “Read more” and “Show less” — are in the HTML; CSS shows the right one with
details[open]. Text generated by CSScontentisn't read reliably by every screen reader, real text is. line-clampcuts after three lines-webkit-line-clamp: 3(still the property every browser supports) ends the paragraph with “…” after three lines — however wide the screen. No fixed height, no guessing.- A checkbox removes the limit
When the visually hidden checkbox is checked,
line-clampis switched off. The checkbox stays reachable by keyboard; its focus ring is drawn on the label. - No
max-height: 1000pxhackAnimating to a large
max-heightis a common trick, but it cuts off long texts and makes the animation timing uneven. Neither version here needs it. - Which one to use
<details>is the more accessible choice for extra sections.line-clampsuits previews of a single paragraph, like a product or tool description.
Copy the HTML and CSS
Version 1: “Read more” with <details>
<div class="ui-more">
<p>Building a website for visitors in mainland China? Three technical decisions matter long before any SEO work starts: where the site is hosted, which fonts it loads, and which third-party scripts it depends on.</p>
<details class="ui-more__details">
<summary class="ui-more__button">
<span class="ui-more__open">Read more</span>
<span class="ui-more__close">Show less</span>
</summary>
<p><strong>Hosting.</strong> A server outside China can be slow or unreliable for Chinese visitors. Hosting inside mainland China requires an ICP filing for the domain.</p>
<p><strong>Fonts.</strong> Google Fonts is not reliably reachable from mainland China. System fonts such as PingFang SC and Microsoft YaHei load instantly.</p>
<p><strong>Scripts.</strong> Google Maps, reCAPTCHA and YouTube embeds don't work in mainland China — and if a page waits for them, it may not load at all.</p>
<p><a href="/tools/chinese-filler-text/#build-for-baidu">See the full build checklist for Baidu</a></p>
</details>
</div>/* "Read more" with <details> — no JavaScript.
The first paragraph is always visible; the rest sits in a
native <details> element. Button text switches with CSS. */
.ui-more {
--ui-text: #1b1f3b;
--ui-muted: #4b5070;
--ui-accent: #4f46e5;
font: 400 1rem/1.7 system-ui, -apple-system, "Segoe UI", sans-serif;
color: var(--ui-muted);
}
.ui-more p {
margin: 0 0 0.9rem;
}
.ui-more strong {
color: var(--ui-text);
}
.ui-more a {
color: var(--ui-accent);
font-weight: 600;
}
/* The button */
.ui-more__button {
display: inline-flex;
align-items: center;
gap: 0.4rem;
margin: 0 0 0.9rem;
color: var(--ui-accent);
font-weight: 600;
cursor: pointer;
list-style: none; /* no default triangle */
}
.ui-more__button::-webkit-details-marker {
display: none;
}
.ui-more__button::after {
content: "";
width: 0.45rem;
height: 0.45rem;
margin-top: -0.2rem;
border-right: 2px solid currentColor;
border-bottom: 2px solid currentColor;
transform: rotate(45deg);
}
.ui-more__button:hover {
text-decoration: underline;
}
.ui-more__button:focus-visible {
outline: 2px solid var(--ui-accent);
outline-offset: 3px;
border-radius: 4px;
}
/* Real text in the HTML for both states — screen readers read the right one */
.ui-more__close {
display: none;
}
.ui-more__details[open] .ui-more__open {
display: none;
}
.ui-more__details[open] .ui-more__close {
display: inline;
}
.ui-more__details[open] > .ui-more__button::after {
margin-top: 0.25rem;
transform: rotate(-135deg);
}Version 2: preview with line-clamp
<div class="ui-clamp">
<input class="ui-clamp__toggle" type="checkbox" id="ui-clamp-1">
<p class="ui-clamp__text">A complete Chinese web font contains well over 20,000 characters and often weighs several megabytes — far too much for a fast page, especially on mobile networks. But a typical website uses only a few thousand different characters. Font subsetting keeps exactly those and drops the rest, which turns a multi-megabyte file into a few hundred kilobytes. Paste your site's text into our free subset generator and it lists the characters, gives you the commands to cut the font, and writes the @font-face CSS — including a fallback for characters you add later.</p>
<label class="ui-clamp__button" for="ui-clamp-1">
<span class="ui-clamp__open">Read more</span>
<span class="ui-clamp__close">Show less</span>
</label>
<p><a href="/tools/chinese-font-subset/">Open the Chinese Font Subset Generator</a></p>
</div>/* "Read more" as a preview — no JavaScript.
The paragraph is cut after 3 lines with "…";
a checkbox removes the limit. */
.ui-clamp {
--ui-text: #1b1f3b;
--ui-muted: #4b5070;
--ui-accent: #4f46e5;
position: relative; /* keeps the hidden checkbox inside */
font: 400 1rem/1.7 system-ui, -apple-system, "Segoe UI", sans-serif;
color: var(--ui-muted);
}
.ui-clamp p {
margin: 0 0 0.9rem;
}
.ui-clamp a {
color: var(--ui-accent);
font-weight: 600;
}
/* Collapsed: 3 lines */
.ui-clamp__text {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
line-clamp: 3;
overflow: hidden;
}
/* Visually hidden checkbox — still reachable by keyboard */
.ui-clamp__toggle {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.ui-clamp__toggle:checked ~ .ui-clamp__text {
display: block;
-webkit-line-clamp: unset;
line-clamp: none;
}
/* The button */
.ui-clamp__button {
display: inline-block;
margin: 0 0 0.9rem;
color: var(--ui-accent);
font-weight: 600;
cursor: pointer;
}
.ui-clamp__button:hover {
text-decoration: underline;
}
.ui-clamp__toggle:focus-visible ~ .ui-clamp__button {
outline: 2px solid var(--ui-accent);
outline-offset: 3px;
border-radius: 4px;
}
.ui-clamp__close,
.ui-clamp__toggle:checked ~ .ui-clamp__button .ui-clamp__open {
display: none;
}
.ui-clamp__toggle:checked ~ .ui-clamp__button .ui-clamp__close {
display: inline;
}Exactly the code running in the demos. All class names start with ui-. In version 2, give every checkbox its own id if you use several previews on one page.
Does collapsed “Read more” text hurt SEO?
Not if it is in the HTML. Google has said that with mobile-first indexing, text in collapsed sections, tabs and accordions is treated like visible text. Baidu reads the HTML it downloads, so text that is there is text it can index.
The myth about display: none. You may read that hiding text with max-height or opacity is safer than display: none, because search engines “penalise hidden content”. There is no such penalty for normal interface patterns like these. What search engines do act against is text hidden to manipulate rankings — keyword lists in white on white, for example. A “Read more” isn't that, whatever CSS property hides it.
The real risk: text that isn't there. Many “Read more” buttons load the rest of the text with JavaScript when clicked. Then the text is missing from the HTML, and crawlers — which don't click — never see it. For Baidu and many AI crawlers, which work mostly with raw HTML, that content simply doesn't exist.
Practical rule: put the sentences a page should rank for in the visible part. Collapse supporting detail, not the core message.
Accessibility and browser support
| Feature | <details> | line-clamp | Details |
|---|---|---|---|
| Keyboard | Works | Works | Enter or Space on the summary; Space on the checkbox. |
| Screen readers | Works | OK | The summary is announced as a button with its state. In the clamped version screen readers read the full text anyway; the toggle is announced as a checkbox. |
| Find in page | Chrome, Edge | Partly | Chrome and Edge open a closed <details> when the search text is inside. Clamped text is found, but may sit in the hidden lines. |
| Browser support | All | All | -webkit-line-clamp works in all current browsers, despite its prefix. |
- Showing the button only when text is actually cut. CSS can't tell whether a clamped paragraph overflows, so short texts still show “Read more”. A few lines of script can hide it — or only use the preview on texts you know are long.
- Animating the height in browsers other than Chrome and Edge. The accordion pattern shows the CSS-only animation where it is supported.
Questions about “Read more” without JavaScript
How do I make a “Read more” button with only HTML and CSS?
Put the extra text inside <details> with a <summary>Read more</summary>. For a preview, cut a paragraph with line-clamp and remove the limit with a checkbox and :checked.
Is hidden “Read more” text bad for SEO?
No, as long as it is in the HTML. Google treats collapsed text like visible text. Text loaded by JavaScript after a click is the real problem.
Is display: none worse for SEO than max-height: 0?
No. Search engines don't judge normal interface patterns by the CSS property that hides them. Both are fine for a “Read more”.
Can “Read more” change to “Show less” without JavaScript?
Yes. Put both texts in the button and show one of them with details[open] or :checked — as in both demos.
Should I use “Read more” on mobile?
Use it for secondary detail, not for the main message. Visitors should understand the page without opening anything.
This FAQ is built without JavaScript — see the accordion pattern.
Is your Chinese content visible to Baidu — and convincing to readers?
We check Chinese pages for content that crawlers can't see, and have native editors review what they can. Then we run Baidu SEO and Chinese content QA for Western companies.
CSS-First UI Patterns are written and maintained by Jademond Digital, a Chinese digital marketing agency founded in Guangzhou in 2012. We build and audit websites for Baidu, Google and AI search — which is why we care what works without JavaScript. About us →