Components: Tab & Accordion
Guides tab and accordion implementation for organizing content without excessive vertical space. Two layout patterns: vertical accordion (FAQ-style, stacked) and horizontal tabs (how-to style, side-by-side). Both improve UX by reducing scroll; SEO impact depends on implementation and content placement.
When invoking: On first use, if helpful, open with 1–2 sentences on what this skill covers and why it matters, then provide the main output. On subsequent use or when the user asks to skip, go directly to the main output.
Layout Patterns
| Pattern | Layout | Best for | Example |
|---|
| Vertical accordion | Stacked; expand/collapse one at a time | FAQ, Q&A, long lists, objection handling | "How do I return?" → answer below |
| Horizontal tabs |
Side-by-side labels; one panel visible | How-to steps, product specs, pricing tiers, comparisons | "Step 1 \| Step 2 \| Step 3" |
Mobile: Vertical accordion works well on small screens (natural scroll). Horizontal tabs can feel cramped—consider accordion, dropdown, or full-width tab bar that scrolls.
SEO: Is It Friendly?
Google's position: Google indexes and ranks content inside tabs and accordions fully; hidden content receives full weight (confirmed since 2016 mobile-first indexing). Gary Illyes: "we index the content, its weight is fully considered for ranking."
Practical nuance: Some tests show always-visible content outperforms hidden content in rankings. Reserve tabs/accordions for secondary content; place primary, keyword-critical content in visible areas.
| Content type | Placement |
|---|
| Primary / ranking-focused | Visible above fold; not hidden |
| Secondary / supporting |
Tabs, accordions acceptable |
|
FAQ answers | Accordion OK; first item expanded by default; see
faq-page-generator |
Indexing Requirements
Content must be in the DOM on page load. Google does not simulate user clicks; it cannot "click" tabs to discover content.
| Implementation | Indexed? |
|---|
| All tab content in HTML at load | ✅ Yes |
| Content loaded via AJAX on tab click |
❌ No |
Recommendation: Server-render all tab content in the initial HTML; use CSS/JS only to show/hide. Prefer <details>/<summary> or equivalent server-rendered markup. See rendering-strategies for SSR, SSG, CSR and crawler visibility.
Horizontal Tabs: More Tabs, More Content?
Technically: Yes—if all content is in the DOM at load, more tabs = more indexable content. Mobile-first indexing gives full weight to tabbed content in HTML.
Strategically: Not always. Signal dilution occurs when many tabs = many different topics on one page. Google may struggle to understand which query the page should rank for; topical authority and keyword focus get spread thin.
| Scenario | Use tabs? | Alternative |
|---|
| Same topic (How-to Step 1/2/3; product specs: dimensions, materials, shipping) | ✅ Yes | — |
| Different topics (Service A, Service B, Portfolio, Blog) |
❌ No | Separate URLs per topic; see
content-strategy for pillar/cluster |
When many horizontal tabs work: All tabs semantically related to one query (e.g., one how-to, one product). When to use separate pages: Each tab is a distinct topic deserving its own URL, crawl, and ranking opportunity.
Implementation
Native HTML (Recommended)
Use <details> and <summary>—no JavaScript required; accessible; crawlable.
CODEBLOCK0
- - First tab/accordion: Add
open attribute so it's expanded by default <summary>: Must be first child of <details>; acts as toggle- Progressive enhancement: Style with CSS; add JS only if needed (e.g., close others when one opens)
JavaScript-Dependent Tabs
If using JS-only tabs: ensure all tab content is in the DOM at page load, not loaded via AJAX on click. Google does not simulate tab clicks. Prefer <details>/<summary> or server-rendered HTML. See rendering-strategies.
Avoid
- - Content loaded only after user click (AJAX, lazy-loaded via fetch)—crawlers will not index it
- INLINECODE9 or
visibility: hidden for primary content—Google may treat differently - Many tabs with unrelated topics on one page—causes signal dilution; use separate URLs instead
Content Best Practices
| Practice | Purpose |
|---|
| First item expanded | Ensures primary content visible on load; better for SEO and UX |
| Descriptive headers |
<summary> / tab labels should clearly describe content; include keywords naturally |
|
Logical structure | H2/H3 for sections; supports snippet extraction; see
featured-snippet |
|
Answer-first | For FAQ: 40–60 words direct answer; then detail; see
faq-page-generator |
Use Cases
| Use case | Format | Layout | Notes |
|---|
| FAQ | Accordion | Vertical | FAQPage schema; first Q expanded; see faq-page-generator |
| How-to steps |
Tabs | Horizontal | Step 1, Step 2, Step 3; sequential flow |
|
Product specs | Tabs | Horizontal | Dimensions, materials, shipping—secondary to hero |
|
Long guides | Accordion | Vertical | Collapsible sections; see
toc-generator |
|
Pricing tiers | Tabs | Horizontal | Compare plans; primary CTA visible |
|
Objection handling | Accordion | Vertical | "What about X?"—supporting conversion |
Schema & Rich Results
- - FAQ (vertical accordion): FAQPage JSON-LD; schema must match on-page content exactly; see schema-markup, faq-page-generator
- How-to (horizontal tabs): HowTo schema for step-by-step content; see schema-markup, featured-snippet
- Other tabs: No specific schema; ensure semantic HTML (headings, structure)
UX & Accessibility
- - Visual indicator: Arrow, plus/minus, or chevron to show expand/collapse state
- Keyboard:
<details>/<summary> natively keyboard-accessible - Core Web Vitals: Avoid layout shift (CLS) when expanding; reserve space or animate smoothly
- Mobile: Touch targets ≥44×44px; vertical accordion often better than horizontal tabs on small screens (tabs can be cramped; accordion scrolls naturally)
Pre-Implementation Checklist
- - [ ] All tab/accordion content in DOM at page load (no AJAX on click)
- [ ] Primary ranking content visible, not hidden
- [ ] First tab/accordion expanded by default
- [ ] Using
<details>/<summary> or equivalent server-rendered HTML - [ ] Headers descriptive; keywords natural
- [ ] Tabs share one topic (avoid signal dilution); if different topics, consider separate pages
- [ ] For FAQ: FAQPage schema matches content
Related Skills
- - faq-page-generator: FAQ structure, answer length, schema; accordion is common FAQ UI
- featured-snippet: Answer-first, H2/H3; content in accordions can be extracted
- schema-markup: FAQPage for FAQ accordions; HowTo for step-by-step tabs
- content-strategy: Pillar/cluster architecture; when to use separate pages vs tabs
- toc-generator: Collapsible TOC; similar disclosure pattern
- content-optimization: Word count, structure, multimedia in expandable sections
- rendering-strategies: SSR, SSG, CSR; content in initial HTML for crawlers
组件:标签页与折叠面板
指导标签页和折叠面板的实现,用于在不占用过多垂直空间的情况下组织内容。两种布局模式:垂直折叠面板(常见问题风格,堆叠式)和水平标签页(操作指南风格,并排式)。两者均通过减少滚动来改善用户体验;对SEO的影响取决于实现方式和内容放置。
调用方式:在首次使用时,如有帮助,先用1-2句话说明此技能涵盖的内容及其重要性,然后提供主要输出。在后续使用或用户要求跳过时,直接进入主要输出。
布局模式
| 模式 | 布局 | 最佳适用场景 | 示例 |
|---|
| 垂直折叠面板 | 堆叠式;一次展开/折叠一个 | 常见问题、问答、长列表、异议处理 | 如何退货? → 下方显示答案 |
| 水平标签页 |
并排标签;一个面板可见 | 操作步骤、产品规格、定价层级、对比 | 步骤1 \| 步骤2 \| 步骤3 |
移动端:垂直折叠面板在小屏幕上表现良好(自然滚动)。水平标签页可能显得局促——考虑使用折叠面板、下拉菜单或可滚动的全宽标签栏。
SEO:对搜索引擎友好吗?
谷歌的立场:谷歌完全索引和排名标签页和折叠面板内的内容;隐藏内容获得完整权重(自2016年移动优先索引以来已确认)。Gary Illyes:我们索引内容,其权重在排名中被充分考虑。
实际细微差别:一些测试显示始终可见的内容在排名中优于隐藏内容。将标签页/折叠面板保留用于次要内容;将主要的、关键词关键的内容放在可见区域。
| 内容类型 | 放置位置 |
|---|
| 主要/排名导向 | 首屏可见;不隐藏 |
| 次要/支持性 |
标签页、折叠面板可接受 |
|
常见问题答案 | 折叠面板可以;默认展开第一项;参见
faq-page-generator |
索引要求
内容必须在页面加载时存在于DOM中。 谷歌不会模拟用户点击;它无法点击标签页来发现内容。
| 实现方式 | 被索引? |
|---|
| 所有标签内容在加载时存在于HTML中 | ✅ 是 |
| 通过AJAX在点击标签时加载内容 |
❌ 否 |
建议:在初始HTML中服务器渲染所有标签内容;仅使用CSS/JS进行显示/隐藏。优先使用/或等效的服务器渲染标记。关于SSR、SSG、CSR和爬虫可见性,参见rendering-strategies。
水平标签页:更多标签,更多内容?
技术上:是的——如果所有内容在加载时都存在于DOM中,更多标签 = 更多可索引内容。移动优先索引给予HTML中标签内容的完整权重。
策略上:并非总是如此。当许多标签 = 一个页面上许多不同主题时,会发生信号稀释。谷歌可能难以理解该页面应针对哪个查询进行排名;主题权威性和关键词焦点被分散。
| 场景 | 使用标签页? | 替代方案 |
|---|
| 相同主题(操作指南步骤1/2/3;产品规格:尺寸、材料、运输) | ✅ 是 | — |
| 不同主题(服务A、服务B、作品集、博客) |
❌ 否 | 每个主题使用独立URL;参见
content-strategy了解支柱/集群 |
何时水平标签页有效:所有标签在语义上与一个查询相关(例如,一个操作指南,一个产品)。何时使用独立页面:每个标签是一个独特的主题,应拥有自己的URL、爬取和排名机会。
实现方式
原生HTML(推荐)
使用和——无需JavaScript;可访问;可爬取。
html
第一个问题(默认展开)
此处为答案内容。
第二个问题
此处为答案内容。
- - 第一个标签/折叠面板:添加open属性使其默认展开
- :必须是
的第一个子元素;充当切换开关 - 渐进增强:使用CSS设置样式;仅在需要时添加JS(例如,打开一个时关闭其他)
依赖JavaScript的标签页
如果使用仅JS的标签页:确保所有标签内容在页面加载时存在于DOM中,而不是在点击时通过AJAX加载。谷歌不会模拟标签点击。优先使用/或服务器渲染的HTML。参见rendering-strategies。
避免
- - 仅在用户点击后加载的内容(AJAX、通过fetch延迟加载)——爬虫不会索引它
- 对主要内容使用display: none或visibility: hidden——谷歌可能区别对待
- 一个页面上有多个不相关主题的标签——导致信号稀释;改用独立URL
内容最佳实践
| 实践 | 目的 |
|---|
| 第一项展开 | 确保主要内容在加载时可见;对SEO和用户体验更好 |
| 描述性标题 |
/标签标签应清晰描述内容;自然地包含关键词 |
| 逻辑结构 | 章节使用H2/H3;支持摘要提取;参见featured-snippet |
| 答案优先 | 对于常见问题:40-60字直接答案;然后是细节;参见faq-page-generator |
使用场景
| 使用场景 | 格式 | 布局 | 备注 |
|---|
| 常见问题 | 折叠面板 | 垂直 | FAQPage模式;第一个问题展开;参见faq-page-generator |
| 操作步骤 |
标签页 | 水平 | 步骤1、步骤2、步骤3;顺序流程 |
| 产品规格 | 标签页 | 水平 | 尺寸、材料、运输——次于主视觉 |
| 长指南 | 折叠面板 | 垂直 | 可折叠章节;参见toc-generator |
| 定价层级 | 标签页 | 水平 | 比较方案;主要CTA可见 |
| 异议处理 | 折叠面板 | 垂直 | 那X呢?——支持转化 |
结构化数据与丰富结果
- - 常见问题(垂直折叠面板):FAQPage JSON-LD;模式必须与页面内容完全匹配;参见schema-markup、faq-page-generator
- 操作指南(水平标签页):HowTo模式用于分步内容;参见schema-markup、featured-snippet
- 其他标签页:无特定模式;确保语义HTML(标题、结构)
用户体验与可访问性
- - 视觉指示器:箭头、加/减号或V形符号显示展开/折叠状态
- 键盘:
/原生支持键盘访问
- 核心网页指标:避免展开时布局偏移(CLS);预留空间或平滑动画
- 移动端:触摸目标≥44×44px;在小屏幕上垂直折叠面板通常优于水平标签页(标签页可能局促;折叠面板自然滚动)
实施前检查清单
- - [ ] 所有标签/折叠面板内容在页面加载时存在于DOM中(点击时无AJAX)
- [ ] 主要排名内容可见,不隐藏
- [ ] 第一个标签/折叠面板默认展开
- [ ] 使用
/或等效的服务器渲染HTML
- [ ] 标题描述性;关键词自然
- [ ] 标签共享一个主题(避免信号稀释);如果主题不同,考虑独立页面
- [ ] 对于常见问题:FAQPage模式与内容匹配
相关技能
- - faq-page-generator:常见问题结构、答案长度、模式;折叠面板是常见问题常见UI
- featured-snippet:答案优先、H2/H3;折叠面板中的内容可被提取
- schema-markup:FAQPage用于常见问题折叠面板;HowTo用于分步标签页
- content-strategy:支柱/集群架构;何时使用独立页面vs标签页
- toc-generator:可折叠目录;类似的显示/隐藏模式
- content-optimization:可展开部分的字数、结构、多媒体
- rendering-strategies:SSR、SSG、CSR;内容在初始HTML中供爬虫使用