The State of Docs Report 2025 is live! Dive in and see why docs matter more than ever:
Read the report
LogoLogo
ProductPricingLog inSign up
  • Documentation
  • Developers
  • Guides
  • Changelog
  • Help Center
  • Getting Started
    • GitBook Documentation
    • Quickstart
    • Importing content
    • GitHub & GitLab Sync
      • Enabling GitHub Sync
      • Enabling GitLab Sync
      • Content configuration
      • GitHub pull request preview
      • Commit messages & Autolink
      • Monorepos
      • Troubleshooting
  • Creating Content
    • Formatting your content
      • Inline content
      • Markdown
    • Content structure
      • Spaces
      • Pages
      • Collections
    • Blocks
      • Paragraphs
      • Headings
      • Unordered lists
      • Ordered lists
      • Task lists
      • Hints
      • Quotes
      • Code blocks
      • Files
      • Images
      • Embedded URLs
      • Tables
      • Cards
      • Tabs
      • Expandable
      • Stepper
      • Drawings
      • Math & TeX
      • Page links
    • Reusable content
    • Broken links
    • Searching content
      • Search & Quick find
      • GitBook AI
    • Writing with GitBook AI
    • Version control
  • API References
    • OpenAPI
      • Add an OpenAPI specification
      • Insert API reference in your docs
    • Guides
      • Structuring your API reference
      • Adding custom code samples
      • Managing API operations
      • Describing enums
      • Integrating with CI/CD
  • Extensions reference
  • Publishing Documentation
    • Publish a docs site
      • Public publishing
      • Private publishing with share links
    • Site structure
      • Content variants
      • Site sections
    • Site customization
      • Icons, colors, and themes
      • Layout and structure
      • Extra configuration
    • Set a custom domain
    • Setting a custom subdirectory
      • Configuring a subdirectory with Cloudflare
      • Configuring a subdirectory with Vercel
    • Site settings
    • Site insights
    • Site redirects
    • Visitor authentication
      • Enabling visitor authentication
      • Setting up Auth0
      • Setting up Azure AD
      • Setting up AWS Cognito
      • Setting up Okta
      • Setting up OIDC
      • Setting up a custom backend
  • LLM-ready docs
  • Collaboration
    • Live edits
    • Change requests
    • PDF export
    • Inviting your team
    • Comments
    • Notifications
  • Integrations
    • Install and manage integrations
    • GitHub Copilot
  • Account management
    • Plans
      • Legacy pricing
      • Sponsored site plan
      • Non-profit plan
      • Billing policy
    • Subscription cancellations
    • Personal settings
    • Organization settings
    • Member management
      • Invite or remove members
      • Roles
      • Teams
      • Permissions and inheritance
    • SSO & SAML
      • SSO Members vs non-SSO
  • Resources
    • GitBook UI
    • Keyboard shortcuts
    • Glossary
Powered by GitBook
LogoLogo

Resources

  • Showcase
  • Enterprise
  • Status

Company

  • Careers
  • Blog
  • Community

Policies

  • Subprocessors
  • Terms of Service
On this page
  • Example of an image block
  • Uploading an image
  • Adding images for light & dark mode
  • Light and dark mode images through GitHub/GitLab Sync
  • Resizing
  • Resizing images through Git Sync
  • Aligning images
  • Representation in Markdown

Was this helpful?

Edit on GitHub
  1. Creating Content
  2. Blocks

Images

Add an image or a gallery of images to a page, add image variants for dark mode, and resize and align images to your needs

Last updated 3 months ago

Was this helpful?

You can insert images into your page, then choose their size and whether to align them to the left, center, or right. You can also optionally include alt text and/or a caption on your image block.

Tip: For accessibility purposes, we recommend setting alt text for your images.

Example of an image block

By default, an image block will appear at full-width.

Uploading an image

There are two ways to add images to your content:

  1. Drag and drop the image from your file management system directly into an empty block on your page.

GitBook allows you to upload images up to 100MB per file.

Create an image gallery

Adding images for light & dark mode

You can set different images for the light and dark mode versions of your published site. GitBook will automatically display the correct image depending on the mode your visitor is in.

In the drop-down menu, choose Add image for Dark mode. Once you’ve set this, you can replace either image from this same menu.

Light and dark mode images through GitHub/GitLab Sync

You can also add light and dark mode images in Markdown through HTML syntax (<picture> and <source>).

For block images, use the <figure> HTML element with a <picture> and <source> in it:

Text before

<figure>
  <picture>
    <source
      srcset="
        https://user-images.githubusercontent.com/3369400/139447912-e0f43f33-6d9f-45f8-be46-2df5bbc91289.png
      "
      media="(prefers-color-scheme: dark)"
    />
    <img
      src="https://user-images.githubusercontent.com/3369400/139448065-39a229ba-4b06-434b-bc67-616e2ed80c8f.png"
      alt="GitHub logo"
    />
  </picture>
  <figcaption>Caption text</figcaption>
</figure>

Text after

For inline images (images that sit inline with text), use the <picture> HTML element with a <source> in it:

Text before the image
<picture
  ><source
    srcset="
      https://user-images.githubusercontent.com/3369400/139447912-e0f43f33-6d9f-45f8-be46-2df5bbc91289.png
    "
    media="(prefers-color-scheme: dark)" />
  <img
    src="https://user-images.githubusercontent.com/3369400/139448065-39a229ba-4b06-434b-bc67-616e2ed80c8f.png"
    alt="The GitHub Logo"
/></picture>
and text after the image

Resizing

  • Small – 25% of the image size

  • Medium – 50% of the image size

  • Large – 75% of the image size

  • Fit – Removes all size specifications and displays either at full size or capped at a maximum width of 735 pixels for larger images.

If your image is wider than the editor, GitBook will limit the image’s width to the editor’s width instead, and resizing will be based on this limit.

Note: When resizing images in an image gallery, the results can differ from resizing an individual image.

Resizing images through Git Sync

If you want more control over the sizing of your image, you can specify the exact size using Markdown in GitHub or GitLab.

When we export an image, we use the HTML tag <img/>. As per the specifications, we can specify the dimensions of the image using the width and height attributes, which only accept values in pixels or a combination of a number and a % sign. Valid variants for specifying the image dimensions are: <img width="100" /> Sets the image to 100 pixels wide <img width="100%" /> Sets the image to full size (although this will be limited by the editor)

Aligning images

By default, image blocks will show your image at its full size, aligned centrally.

Representation in Markdown

//Simple Block
![](https://gitbook.com/images/gitbook.png)

//Block with Caption
![The GitBook Logo](https://gitbook.com/images/gitbook.png)

//Block with Alt text

<figure><img src="https://gitbook.com/images/gitbook.png" alt="The GitBook Logo"></figure>

//Block with Caption and Alt text

<figure><img src="https://gitbook.com/images/gitbook.png" alt="The GitBook Logo"><figcaption><p>GitBook Logo</p></figcaption></figure>

//Block with different image for dark and light mode, with caption

<figure>
  <picture>
    <source srcset="https://user-images.githubusercontent.com/3369400/139447912-e0f43f33-6d9f-45f8-be46-2df5bbc91289.png" media="(prefers-color-scheme: dark)">
    <img src="https://user-images.githubusercontent.com/3369400/139448065-39a229ba-4b06-434b-bc67-616e2ed80c8f.png" alt="GitHub logo">
  </picture>
  <figcaption>Caption text</figcaption>
</figure>

to your page and use the Select images side panel that appears on the right of the window.

If you follow the second process, you can choose to upload a file, select a previously-uploaded file, paste an image URL or add an image from using the built-in search.

Adding more than one image to an image block will create a gallery. To do this, open the block’s Options menu and choose Add images… to open the Select images side panel again.

To delete an image from a gallery, open the Actions menu on the image you want to delete and press the Delete ⌫ key.

To add an image for dark mode, hover over your image, open the Actions menu and click Replace image .

Note: GitBook doesn’t currently support light and dark mode images for certain cases, including page covers or image covers on .

Note: We don’t yet support through #gh-dark-mode-only or #gh-light-mode-only.

To resize your image, hover over it and open the Actions menu . Click the Size button to change the size of your image from the available options.

You can make image blocks by clicking on the Options menu next to the block and choosing Full width.

To change the alignment of an image, open the block’s Options menu and choose the alignment you want. This will only affect images that are narrower than the editor, or images you’ve .

Unsplash
cards
GitHub-only syntax
resized
Resize an image
Add an image block
span the full width of your window