Table Width - Asciidoctor Docs

AsciiDoc

    • Introduction
      • Document Structure
      • Key Concepts
      • Document Processing
      • Normalization
    • Blocks
      • Delimited Blocks
      • Build a Basic Block
      • Add a Title to a Block
      • Assign an ID
      • Block Masquerading
      • Troubleshooting Blocks
    • Document Attributes
      • Attribute Entries
        • Attribute Entry Names and Values
        • Wrap Attribute Entry Values
        • Attribute Entry Substitutions
        • Inline Attribute Entries
      • Declare Built-In Attributes
        • Set Boolean Attributes
      • Declare Custom Attributes
      • Unset Attributes
      • Reference Attributes
        • Handle Unresolved References
      • Attribute Assignment Precedence
      • Counters
    • Element Attributes
      • Positional and Named Attributes
      • ID Attribute
      • Role Attribute
      • Options Attribute
    • Document Header
      • Document Title
        • Subtitle
      • Author Information
        • Using the Author Line
        • Add Multiple Authors to a Document
        • Assign Author and Email with Attribute Entries
        • Reference the Author Information
        • Compound Author Names
      • Revision Information
        • Using the Revision Line
        • Assign Revision Attributes with Attribute Entries
        • Version Label Attribute
        • Reference the Revision Attributes
      • Document Metadata
      • Document Header Reference
    • Document Type
    • Sections
      • Section Titles and Levels
        • Activate Section Title Links
      • Autogenerate Section IDs
        • Change the ID Prefix and Separator
      • Assign Custom IDs and Reference Text
      • Section Numbers
      • Section Styles for Articles and Books
        • Hide Special Section Titles
        • Number Special Sections
        • Colophon
        • Dedication
        • Abstract (Section)
        • Abstract (Block)
        • Preface
        • Book Parts
          • Part Numbers and Signifier
        • Chapters
        • Appendix
        • Glossary
        • Bibliography
        • Index
      • Section Attributes and Styles Reference
    • Paragraphs
      • Hard Line Breaks
      • Preamble and Lead Style
      • Paragraph Alignment
    • Discrete Headings
    • Breaks
    • Text Formatting and Punctuation
      • Bold
      • Italic
      • Monospace
      • Literal Monospace
      • Text Span and Built-in Roles
      • Highlight
      • Quotation Marks and Apostrophes
      • Subscript and Superscript
      • Using Custom Inline Styles
      • Troubleshoot Unconstrained Formatting Pairs
    • Lists
      • Unordered Lists
      • Ordered Lists
      • Checklists
      • Separating Lists
      • Compound List Items
    • Description Lists
      • Horizontal Description List
      • Question and Answer Lists
      • Description Lists With Marker
    • Links
      • Autolinks
      • URL Macro
      • Link Macro
      • Troubleshooting Complex URLs
      • Link & URL Macro Attribute Parsing
      • Mailto Macro
      • Link, URL, and Mailto Macro Attributes Reference
    • Cross References
      • Document to Document Cross References
      • Cross Reference Text and Styles
      • Validate Cross References
    • Footnotes
    • Images
      • Set the Images Directory
      • Insert Images from a URL
      • Position and Frame Images
      • Add Link to Image
      • Adjust Image Sizes
      • Specify Image Format
      • SVG Images
      • Images Reference
    • Audio and Video
    • Icons
      • Image Icons Mode
      • Font Icons Mode
      • Icon Macro
    • Keyboard Macro
    • Button and Menu UI Macros
    • Admonitions
    • Sidebars
    • Example Blocks
    • Blockquotes
    • Verses
    • Verbatim and Source Blocks
      • Source Code Blocks
        • Source Highlighting
        • Highlight Select Lines
        • Highlight PHP Source Code
      • Listing Blocks
      • Literal Blocks
      • Callouts
    • Tables
      • Build a Basic Table
      • Add a Title
        • Customize the Title Label
        • Turn Off the Title Label
      • Add Columns to a Table
        • Adjust Column Widths
        • Align Content by Column
        • Format Content by Column
      • Add Cells and Rows to a Table
        • Create a Header Row
        • Create a Footer Row
        • Align Content by Cell
        • Format Content by Cell
        • Span Columns and Rows
        • Duplicate Cells
      • Table Width
      • Table Borders
      • Table Striping
      • Table Orientation
      • Assign a Role to a Table
      • Nesting Tables
      • CSV, TSV and DSV Data
      • Table Reference
    • Equations and Formulas (STEM)
    • Open Blocks
    • Collapsible Blocks
    • Comments
    • Automatic Table of Contents
      • Customize the TOC Title
      • Adjust the TOC Depth
      • Position the TOC
      • TOC Attributes Reference
    • Docinfo Files
    • Includes
      • Offset Section Levels
      • Indent Included Content
      • Use an Include File Multiple Times
      • Include List Item Content
      • Include Content by Tagged Regions
      • Include Content by Line Ranges
      • Include Content by URI
    • Conditionals
      • ifdef and ifndef Directives
      • ifeval Directive
    • Substitutions
      • Special Characters
      • Quotes
      • Attribute References
      • Character Replacements
      • Macros
      • Post Replacements
      • Customize the Substitutions Applied to Blocks
      • Customize the Substitutions Applied to Text
      • Escape and Prevent Substitutions
    • Passthroughs
      • Passthrough Blocks
      • Inline Passthroughs
    • Reference
      • Syntax Quick Reference
      • Frequently Asked Questions (FAQ)
      • Compare AsciiDoc to Markdown
      • Document Attributes Reference
      • Character Replacement Attributes Reference
      • Glossary of Terms
AsciiDoc pre-spec
  • AsciiDoc
  • Asciidoctor
    • 2.0
  • Asciidoctor.js
    • 3.0
    • 2.2
  • AsciidoctorJ
    • 3.0
    • 2.5
  • Asciidoctor PDF
    • 2.3
    • 2.2
    • 2.1
    • 2.0
  • Asciidoctor EPUB3
    • 2.3
  • Asciidoctor reveal.js
    • 5.0
    • 4.1
  • Maven Tools
    • 3.2
  • Gradle Plugin Suite
    • 5.0
    • 4.0
  • Asciidoclet
    • 2.0
    • 1.5.6
  • Asciidoctor Diagram
    • 3.0.1
  • Browser Extension
  • Community
  • AsciiDoc
  • Tables
  • Table Width
PDF Edit this Page Table Width

By default, a table will span the width of the content area.

Fixed width

To constrain the width of the table to a fixed value, set the width attribute in the table’s attribute list. The width is an integer percentage value ranging from 1 to 100. The % sign is optional.

Example 1. Table with width set to 75% [width=75%] |=== |Column 1, header row |Column 2, header row |Column 3, header row |Cell in column 1, row 2 |Cell in column 2, row 2 |Cell in column 3, row 2 |Cell in column 1, row 3 |Cell in column 2, row 3 |Cell in column 3, row 3 |=== Result of Example 1
Column 1, header row Column 2, header row Column 3, header row

Cell in column 1, row 2

Cell in column 2, row 2

Cell in column 3, row 2

Cell in column 1, row 3

Cell in column 2, row 3

Cell in column 3, row 3

Autowidth

Alternately, you can make the width fit the content by setting the autowidth option. The columns inherit this setting, so individual columns will also be sized according to the content.

Example 2. Table using autowidth [%autowidth] |=== |Column 1, header row |Column 2, header row |Column 3, header row |Cell in column 1, row 2 |Cell in column 2, row 2 |Cell in column 3, row 2 |Cell in column 1, row 3 |Cell in column 2, row 3 |Cell in column 3, row 3 |=== Result of Example 2
Column 1, header row Column 2, header row Column 3, header row

Cell in column 1, row 2

Cell in column 2, row 2

Cell in column 3, row 2

Cell in column 1, row 3

Cell in column 2, row 3

Cell in column 3, row 3

If you want each column to have an automatic width, but want the table to span the width of the content area, add the stretch role to the table. (Alternatively, you can set the width attribute to 100%.)

Example 3. Full-width table with autowidth columns [%autowidth.stretch] |=== |Column 1, header row |Column 2, header row |Column 3, header row |Cell in column 1, row 2 |Cell in column 2, row 2 |Cell in column 3, row 2 |Cell in column 1, row 3 |Cell in column 2, row 3 |Cell in column 3, row 3 |===

The table from Example 3 is rendered below. The columns are sized to the content, but the table spans the width of the page.

Result of Example 3
Column 1, header row Column 2, header row Column 3, header row

Cell in column 1, row 2

Cell in column 2, row 2

Cell in column 3, row 2

Cell in column 1, row 3

Cell in column 2, row 3

Cell in column 3, row 3

The autowidth option is not recognized by the DocBook converter.

Mix fixed and autowidth columns

If you want to apply autowidth only to certain columns, use the special value ~ as the width of the column. In this case, width values are assumed to be a percentage value (i.e., 100-based).

Example 4. Table with fixed and autowidth columns [cols="25h,~,~"] |=== |small |as big as the column needs to be |the rest |=== Result of Example 4

small

as big as the column needs to be

the rest

Duplicate Cells Table Borders

Từ khóa » Html Stretch Table To Full Width