html

JavaScriptからhtmlファイルのロード

stackoverflow.com <script> fetch('page.html') .then(data => data.text()) .then(html => document.getElementById('elementID').innerHTML = html); </script> <div id='elementID'> </div>

templatesとslots

概要 webコンポーネントのshadow DOMとしてポピュラーに使用されている templatesについて より簡単にマークアップを使い回す事ができる。 template要素とその中身はDOM内にはレンダーされないが、 JavaScriptを通して参照することが可能。 簡単なtemplate例 <template id="my-paragraph"></template>…

記事の書き方 in HTML

構造 <main> <section> <article> <h1> <p> main documentに対して一つだけ定義する section カテゴライズするためのタグ。 documentに対して複数定義でき、article 内部に含めることも可能。 article 一つの記事を表すタグ。 例 <body> <main> <h1>献立メニュー</h1> <p>今月のおすすめ献立メニュー一覧</p> <section> <h1>肉料理</h1> <p>肉</p></section></main></body></p></h1></article></section></main>…