Advent

Day 12: Figure 🖼️

A figure element represents a graphic asset with an optional caption.

The example component is visible below.


Silvestar's profile image in black and white.
Silvestar (b&w)

A few notes about this picture component:

  • CSS Variables are used for colors,
  • the srcset attribute is used to define the sizes of the image based on pixel density,
  • the source element is used to define the MIME type of the image,
  • the loading="lazy" attribute is used to notify the browser to download the image when the user scrolls near the component.

The code:

<figure class="advent-figure">
  <picture>
    <source srcset="https://res.cloudinary.com/starbist/image/upload/w_600,h_600/v1638533826/PSX_20210122_073918_k01l3d.webp 2x, https://res.cloudinary.com/starbist/image/upload/w_300,h_300/v1638533826/PSX_20210122_073918_k01l3d.webp 1x" type="image/webp">
    <img srcset="https://res.cloudinary.com/starbist/image/upload/w_600,h_600/v1638533826/PSX_20210122_073918_k01l3d.jpg 2x, https://res.cloudinary.com/starbist/image/upload/w_300,h_300/v1638533826/PSX_20210122_073918_k01l3d.jpg 1x" src="https://res.cloudinary.com/starbist/image/upload/w_300,h_300/v1638533826/PSX_20210122_073918_k01l3d.jpg" alt="Silvestar's profile image in black and white." width="300" height="300">
  </picture>
  <figcaption>Silvestar</figcaption>
</figure>
.advent-figure {
  --color-xmas-alpha: #f7efef;

  all: unset;
}

.advent-figure img {
  background-color: var(--color-xmas-alpha);
}

.advent-figure figcaption {
  font-size: 70%;
  font-style: italic;
  opacity: 0.7;
}

Advent of UI components 🎄

Check other UI components.

Day 24: Details 🎹

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 24: Details.

Day 23: Radio button 📱

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 23: Radio button.

Day 22: Checkbox 🧦

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 22: Checkbox.

Day 21: Notification 🤫

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 21: Notification.

Day 20: Code block 💻

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 20: Code block.

Day 19: Pagination 📖

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 19: Pagination.

Day 18: Social share 🔗

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 18: Social share.

Day 17: Card 🎴

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 17: Card.

Day 16: Table 🎶

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 16: Table.

Day 15: Breadcrumb 🍞

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 15: Breadcrumb.

Day 14: Blockquote 💬

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 14: Blockquote.

Day 13: List 🗒️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 13: List.

Day 11: Video embed 📺

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 11: Video embed.

Day 10: Footer 👇

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 10: Footer.

Day 9: Header ☝️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 9: Header.

Day 8: Hero 🦸‍♂️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 8: Hero.

Day 7: Intro 💬

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 7: Intro.

Day 6: Horizontal rule 〰️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 6: Horizontal rule.

Day 5: Split 💔

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 5: Split.

Day 4: Banner 🚩

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 4: Banner.

Day 3: Gallery 🍿

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 3: Gallery.

Day 2: Tag 🎁

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 2: Tag.

Day 1: Button 🎅

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 1: Button.