Issue with HTML Table Styling in Databricks Alerts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 06:53 AM
Hi Community,
I’m trying to create an alert in Databricks with a custom email notification that includes the results of a SQL query displayed in an HTML table. However, I am facing issues with styling the table, specifically with adding borders and background colors to the headers.
Here is the HTML code I am currently using:
<table border="1" cellpadding="5" cellspacing="0">
<tr style="background-color: black; color: white; font-weight: bold;">
<th>Project Name</th>
<th>Jira ID</th>
<th>Category</th>
<th>Site</th>
</tr>
<tbody>
{{#QUERY_RESULT_ROWS}}
<tr>
<td>{{Project_Name}}</td>
<td>{{Jira_ID}}</td>
<td>{{Category_1}}</td>
<td>{{Site}}</td>
</tr>
{{/QUERY_RESULT_ROWS}}
</tbody>
</table>
The table renders correctly with the data, but the following issues persist:
- Borders do not appear around the cells.
- Background color for the header row doesn’t display.
- Overall table styling (such as cellpadding and cellspacing) doesn’t seem to be applied.
I have tried several variations, including inline styles, but nothing seems to work. Is there a limitation with HTML and CSS in Databricks alerts, or am I missing something in the implementation?
Any guidance or solutions on how to display a properly styled table in the alert email would be greatly appreciated!
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 07:34 AM
Hi @VKe ,
That's because only subsets of html tags and attributes are supported in alerts:
You can use HTML to format messages in a custom template. The following tags and attributes are allowed in templates:
https://docs.databricks.com/en/sql/user/alerts/index.html
Tags: <a>, <abbr>, <acronym>, <b>, <blockquote>, <body>, <br>, <code>, <div>, <em>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <head>, <hr>, <html>, <i>, <li>, <ol>, <p>, <span>, <strong>, <table>, <tbody>, <td>, <th>, <tr>, <ul>
Attributes: href (for <a>), title (for <a>, <abbr>, <acronym>)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 09:23 AM
Hi @szymon_dybczak!
Thank you for your response!
I had seen the list of supported HTML tags in the documentation, but I couldn’t believe that it wouldn’t be possible to format an email neatly. I was hoping that there might still be a way to achieve a cleaner, more styled layout for the alert notifications.
It’s a bit surprising that we’re so limited in formatting options, but I appreciate your clarification.
Thanks again for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 09:31 AM
Hi @VKe ,
No problem. I had the same requirement and I must admit I was also surprised that only a subset of attributes and tags are currently supported.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 10:08 PM
Hi @VKe , @szymon_dybczak ,
{{#QUERY_RESULT_ROWS}} and {{/QUERY_RESULT_ROWS}} used to work like a charm in presenting query result in custom alert email, but now the results are showing up blank in my alert notifications. Are you experiencing the same?

