# Adding JavaScript to your HTML file
##### Using the `defer` attriute
```html
<head>
<script src="js-file.js" defer></script>
</head>
```
The `defer` attribute ensures that your JavaScript code runs after the DOM is fully constructed but before the `DOMContentLoaded` event fires. This allows your code to access and manipulate the DOM elements safely, without the need to wait for the `load` event or place the `<script>` tag at the end of the `<body>` section.
# Tables
- HTML tables are used to represent tabular data.
- Avoid using tables for layout. It's inaccessible, not responsive, and hard to maintain.
- Use semantic elements: `<thead>`, `<tbody>`, `<tfoot>`, `<caption>`, etc.
<table style="border: 1px solid gray; width: 400px">
<caption>Example 2x2 table with headers (Renders in Obsidian)</caption>
<tr>
<th style="border: 1px solid gray;">Header 1</th>
<th style="border: 1px solid gray;">Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>