# Part 2: Advanced Structures & Elements


Explore more powerful DML capabilities for building complex, responsive email blocks with advanced layout patterns and components. This section focuses on extending basic structures into more flexible and customizable designs.

# Structures

In [Part 1](/dml_101/part1_basics), we discussed the basic structural elements of a DML block and some of their default settings and behaviors.  In this part, we will cover ways to modify that default behavior, so that you can take more direct control over the layout of your email.

## <a href="https://docs.dyspatch.io/dml/#dys-divider">dys-divider</a> & <a href="https://docs.dyspatch.io/dml/#dys-spacer">dys-spacer</a>

Use these to create a divider line or add extra vertical space to your layout.  Check the DML Documentation, linked above, for details on which attributes are available to be modified.

<div class="hide-when-iframe">

```
<dys-block>
  <dys-row>
    <dys-column>
      <dys-text>
      	Top Text
      </dys-text>
      <dys-divider/>
      <dys-text>
      	Bottom Text
      </dys-text>
    </dys-column>
        <dys-column>
      <dys-text>
      	Top Text
      </dys-text>
      <dys-spacer container-background-color="lightgrey"/>
      <dys-text>
      	Bottom Text
      </dys-text>
    </dys-column>
  </dys-row>
</dys-block>
```

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/dys-divider-dys-spacer.png" alt="Example block using dys-divider and dys-spacer">

View in <a href="https://dml-playground.dyspatch.io/3qNs6V21nRmhegY0e6159QX5UKCgnsHss6r">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/3qNs6V21nRmhegY0e6159QX5UKCgnsHss6r" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>

## Grouping Columns with <a href="https://docs.dyspatch.io/dml/#dys-group">dys-group</a>
By default, columns will stack vertically in mobile view.  If you would like to change this behavior, wrap your columns in `<dys-group>` to keep them next to each other.

<div class="hide-when-iframe">

```
<dys-block>
  <dys-row>
    <dys-column background-color="lightblue">
      <dys-text>
        Column 1
      </dys-text>
    </dys-column>
    <dys-column background-color="lightgreen">
      <dys-text>
        Column 2
      </dys-text>
    </dys-column>
  </dys-row>
  <dys-row>
    <dys-group>
      <dys-column background-color="lightpink">
        <dys-text>
          Column 3 - Group
        </dys-text>
      </dys-column>
      <dys-column background-color="lightyellow">
        <dys-text>
          Column 4 - Group
        </dys-text>
      </dys-column>
    </dys-group>
  </dys-row>
</dys-block>
```
Desktop:
<img class="img-border" src="https://docs.dyspatch.io/img/dml101/dys-group-desktop.png" alt="In desktop view, all columns will display in a horizontal row">

Mobile:
<img class="img-border" src="https://docs.dyspatch.io/img/dml101/dys-group-mobile.png" alt="In mobile view, columns wrapped in dys-group will remain in a horizontal row">

View in <a href="https://dml-playground.dyspatch.io/Ri8yHdAP5JN8MdgF3xwaNP5fbjzXpO1HENM">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/Ri8yHdAP5JN8MdgF3xwaNP5fbjzXpO1HENM" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>

## <a href="https://docs.dyspatch.io/dml/#dys-mobile">dys-mobile</a> & <a href="https://docs.dyspatch.io/dml/#dys-desktop">dys-desktop</a>

These tags allow you to take direct control over your desktop and mobile views. Content wrapped in `<dys-desktop>` will only display on large screens, and content inside `<dys-mobile>` will only display on small screens.  This comes in handy for situations like using different images for desktop and mobile, or having a shorter title for smaller screens to avoid a line break.

<div class="hide-when-iframe">

```
<dys-block>
  <dys-row>
    <dys-column>
      <dys-desktop>
        <dys-title color="red">
          Desktop Content
        </dys-title>
        <dys-img src="https://cdn-web-assets.dyspatch.io/org_01hpj7c8chj0ckh13ezdyb78v9/FNW54MNIRoiwE9H5gPJ7_example-photo-library.jpeg"/>
      </dys-desktop>
      <dys-mobile>
        <dys-title color="blue">
          Mobile Content
        </dys-title>
        <dys-img src="https://cdn-web-assets.dyspatch.io/org_01hpj7c8chj0ckh13ezdyb78v9/yHytamYSS5Cd9UYQANNg_example-photo-yard.jpeg"/>
      </dys-mobile>
    </dys-column>
  </dys-row>
</dys-block>
```

Desktop:
<img class="img-border" src="https://docs.dyspatch.io/img/dml101/dys-desktop.png" alt="In desktop view, dys-desktop content will be displayed">

Mobile:
<img class="img-border" src="https://docs.dyspatch.io/img/dml101/dys-mobile.png" alt="In mobile view, dys-mobile content will be displayed">

View in <a href="https://dml-playground.dyspatch.io/tCyIewUFt8yKZS1dh8AqnoatzbJGxV6TUO9">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/tCyIewUFt8yKZS1dh8AqnoatzbJGxV6TUO9" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>

# Elements
In this section, we will  give a quick overview of the remaining DML elements, as well as examples in the DML Playground, so that you can see them in action.

## <a href="https://docs.dyspatch.io/dml/#dys-hero">dys-hero</a>

- Used in place of dys-row
- Allows you to set a background image which can have editable text on top
- Great way to draw attention to the most important part of your email
- Fluid height vs fixed height determines image display on smaller screens
- Setting a fallback background-color will help your content stand out if the user's email client has images turned off by default

<div class="hide-when-iframe">

```
<dys-block>
  <dys-hero background-url="https://picsum.photos/id/536/600/400"
            background-width="600px"
            background-color="#000033"
            background-height="250px"
            height="250px"
            mode="fixed-height"
            vertical-align="middle"
            editable="hero">
    <dys-title color="#FFFFFF" editable="title" font-weight="bold">
      Your Title
    </dys-title>
    <dys-text color="#FFFFFF" editable="subtitle" font-size="20px">
      Your title and text will sit on top of the background image
    </dys-text>
  </dys-hero>
</dys-block>
```

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/dys-hero.png" alt="DML block using dys-hero">

View in <a href="https://dml-playground.dyspatch.io/0B0CIwdXVIKq7ca4jW7cxYZy3cCbCnGBJaa">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/0B0CIwdXVIKq7ca4jW7cxYZy3cCbCnGBJaa" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>

## <a href="https://docs.dyspatch.io/dml/#dys-table">dys-table</a>

- Creates an HTML table in your email
- Specific cells can be marked as editable
- Can be used dynamically — more on that in [Part 3](/dml_101/part3_templating/#loops--a-hrefhttpsdocsdyspatchiodmldys-fordys-fora)!

<div class="hide-when-iframe">

```
<dys-block>
<dys-row>
    <dys-column>
      <dys-table padding-left='50px' padding-right='50px'>
        <tr>
          <th style='border-bottom:1px solid #ecedee;text-align:left;'
            editable='th1'>
            Item
          </th>
          <th style='border-bottom:1px solid #ecedee;text-align:right;'
            editable='th2'>
            Price
          </th>
        </tr>
        <tr>
          <td style='text-align:left;'>
            Apples
          </td>
          <td style='text-align:right;'>
            $1.00/lb
          </td>
        </tr>
        <tr>
          <td style='text-align:left'>
            Oranges
          </td>
          <td style='text-align:right;'>
            $1.22/lb
          </td>
        </tr>
      </dys-table>
    </dys-column>
  </dys-row>
</dys-block>
```

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/dys-table.png" alt="DML block using dys-table">

View in <a href="https://dml-playground.dyspatch.io/gbiS7S0Phj5tVtBnTTbbeTwRCYw04GodAZG">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/gbiS7S0Phj5tVtBnTTbbeTwRCYw04GodAZG" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>


## <a href="https://docs.dyspatch.io/dml/#dys-social">dys-social</a>

- Built-in social media icons — full list available in our <a href="https://docs.dyspatch.io/dml/#dys-social">DML Documentation</a>
- Default icons available in color, black, or white
- Defaults include circle, square, or default icon shapes
- Ability to upload and use custom icons in dys-social

<div class="hide-when-iframe">

```
<dys-block>
  <dys-row>
    <dys-column>
      <dys-text align="center" font-weight="bold">Follow us!</dys-text>
      <dys-social icon-size="30px" theme="color" shape="circle">
        <dys-social-element name="facebook" href="https://example.com/">
          Facebook
        </dys-social-element>
        <dys-social-element name="twitter" href="https://example.com/">
          Twitter
        </dys-social-element>
        <dys-social-element name="linkedin" href="https://example.com/">
          Linkedin
        </dys-social-element>
      </dys-social>
    </dys-column>
  </dys-row>
</dys-block>
```

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/dys-social.png" alt="DML block using dys-social">

View in <a href="https://dml-playground.dyspatch.io/p0SZjhMLsgwt0qIcEPddjcqAQKXmXudDhFy">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/p0SZjhMLsgwt0qIcEPddjcqAQKXmXudDhFy" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>



## <a href="https://docs.dyspatch.io/dml/#dys-carousel">dys-carousel</a>

- Carousel display of multiple images
- Click arrows or thumbnail images to change view
- In email clients where it’s  not supported (like Outlook), dys-carousel will automatically fallback to hide arrows and display the first image only

<div class="hide-when-iframe">

```
<dys-block>
  <dys-row>
    <dys-column>
      <dys-carousel editable='carousel'>
        <dys-carousel-image src='https://picsum.photos/id/536/600/400' />
        <dys-carousel-image src='https://picsum.photos/id/110/600/400' />
        <dys-carousel-image src='https://picsum.photos/id/410/600/400' />
      </dys-carousel>
    </dys-column>
  </dys-row>
</dys-block>
```

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/dys-carousel.png" alt="DML block using dys-carousel">

View in <a href="https://dml-playground.dyspatch.io/1v5faJESQC10l9ma2cjJlUgFl7uDXsBt40Y">DML Playground</a>

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/1v5faJESQC10l9ma2cjJlUgFl7uDXsBt40Y" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>


## Practice

Now that we’ve covered the building blocks of DML,  it’s time to create your own DML block from scratch.  Here’s a block created using `<dys-desktop>`/`<dys-mobile>`, `<dys-divider>`, `<dys-social>`, and some of the basic elements from [Part 1](/dml_101/part1_basics/).  Try to re-create this as accurately as possible in the <a href="https://dml-playground.dyspatch.io/">DML Playground</a>. When you’re ready, check out the <a href="https://dml-playground.dyspatch.io/QELrO2S4emS9gXbnsodjIjEgOICMmBwSdhT">solution</a>.  When you’ve finished, feel free to try styling the block using attributes!

<div class="hide-when-iframe">

Desktop:

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/part2-desktop.png" alt="Practice block in desktop view">


Mobile:

<img class="img-border img-center" src="https://docs.dyspatch.io/img/dml101/part2-mobile.png" alt="Practice block in mobile view">

</div>

<div class="hide-on-small-screens">

<div class="allow-overflow">
  <div class="floating-column-left">

  <p class="mini-margin">Desktop:</p>

  <img class="img-border img-center mini-margin" src="https://docs.dyspatch.io/img/dml101/part2-desktop.png" alt="Practice block in desktop view">

  </div>

  <div class="floating-column-right">

  <p class="mini-margin">Mobile:</p>

  <img class="img-border img-center mini-margin" src="https://docs.dyspatch.io/img/dml101/part2-mobile.png" alt="Practice block in mobile view">

  </div>

</div>

<div class="allow-overflow img-border" width="1000px">

<iframe src="https://dml-playground.dyspatch.io/" sandbox="allow-scripts allow-popups allow-same-origin" loading="lazy" width="1000px" height="500px"></iframe>

</div>
</div>