Web UI を構築できるように自分自身を開発する: パート HTML を理解する

WBOY
リリース: 2024-08-16 17:01:43
オリジナル
1175 人が閲覧しました

Web 開発は、今日最も需要の高いスキルの 1 つです。これには、ブラウザ経由でアクセスできる、ユーザーフレンドリーで魅力的な Web サイトを作成することが含まれます。 Web 開発者になるための最初のステップは、HTML を理解することです。

Develop yourself to build Web UIs: Part  Understanding HTML

HTML (ハイパー テキスト マークアップ言語) は、あらゆる Web ページのバックボーンです。これは、Web ページを構造化し、ブラウザーでのコンテンツの表示方法を決定するために使用される標準言語です。ページの外観は CSS (Cascading Style Sheets) によって決まり、その機能は JS (Javascript) によって決まりますが、HTML は、基本的なスケルトンまたは構造を担当します。

コースのこの部分に入る前に、旅の中で使用される有名な専門用語や繰り返し使用される専門用語を理解することが重要です。これらは、作業を進めるにつれて概念を理解するのに役立ちます (また、作成者が物事を説明しやすくなります ;-) )。


専門用語を理解する

  1. プログラミング言語: コンピューターが実行できる特定の構文 (プログラミング言語の方法) で記述された一連の命令。コンピューターはバイナリ コード (1 または 0) のみを理解することを忘れないでください。コンピューターにロジックを理解させ、トレードオフを見つけるために、私たち (人間) は、簡単に理解できるようなプログラミング言語を作成しました。私たちがコードを書くだけでなく、コンピューターもそれを理解することができます。
  2. コンパイラー: プログラミング言語で書かれたコードを、コンピューターが理解して実行できる機械語に変換するツール。
  3. 構文: プログラミング言語の構造を定義する規則。これは、文中で意味をなすために単語を配置する方法と考えてください。
  4. コメント: コードの特定の部分が何を行うかを説明するコード内のメモ。コメントは、他の開発者 (または将来のあなた) がコードの背後にあるロジックを理解するのに役立ちます。
  5. DOM (Document Object Model): DOM は、HTML ドキュメントをツリー状に表現したものです。 HTML 内のすべてのタグは、このツリー内のノードになります。たとえば、HTML に がある場合、

    のタグ(段落) その中に、ブラウザは段落ノードを子として持つ本文ノードを作成します。

  6. 子供: 上達するにつれて、これを理解できるようになります。別の要素内にネストされた要素。たとえば、HTML では、div タグ (
    ) 内の段落タグ (

    ) は div の子とみなされます。

  7. ブロックレベル要素: 作業を進めていくと、この専門用語を学ぶことになります。この用語は通常、要素が利用可能な幅をすべて占めるという要素の機能を表します。

HTML を起動する

HTMLハイパー テキスト マークアップ言語

を表します。
  • ハイパー テキスト: 異なるドキュメントをリンクする HTML の機能を指します。

  • マークアップ言語: タグを使用してテキストに注釈を付け、ブラウザーでの表示方法を定義します。

HTML ドキュメントの基本構造は次のとおりです:

<!DOCTYPE html>
<html>
  <head>
    <title>HTML Tutorial</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>
ログイン後にコピー
  • タグ: HTML では、タグは要素を定義するために使用されます。タグは、 のように山括弧で囲みます。または

  • 要素: 開始タグと終了タグで構成され、コンテンツが含まれる場合があります。たとえば、

    Hello, world!

    は段落要素です。


HTML文書の構造

すべての HTML ドキュメントは次の基本構造に従います。

  1. : Declares the document type and version of HTML.
  2. : The root element that encloses all other HTML elements.
  3. : Contains meta-information about the document, such as the title and links to stylesheets.
  4. : Sets the title of the webpage, displayed in the browser's title bar or tab.
  5. : Provides metadata about the HTML document, such as character set, author, and viewport settings. It's a self-closing tag.
  6. : Embeds CSS code to style the HTML elements.
  7. <script></script>: Embeds JavaScript code for adding interactivity to the webpage.
  8. : Encloses the content that will be visible to users on the webpage.

Commonly Used HTML Elements

Here are some basic HTML elements you’ll use frequently:

  • : Defines a paragraph.
  • : A block-level element used to group other elements together.
  • : An inline element used to group text for styling purposes.
  • : Represents the introductory content or navigational links of a section.
  • to
    : Headings, with

    being the highest level and

    the lowest.

  • : Inserts a line break (self-closing tag — meaning there is no need to close the tag).
  • : Used to create an HTML form for user input.
  • : Creates an input field, typically used within a form.
  • : Creates a dropdown list.
  • : Associates a text label with a form element.
  • : Defines a table.
  • : Defines a row in a table.
  • : Defines a cell in a table row.
  • : Defines a header cell in a table row.
    • : Defines an unordered (bulleted) list.
      1. : Defines an ordered (numbered) list.
      2. : Defines a list item.

      Creating Your First HTML File

      To create an HTML file, you can use any text editor, such as Notepad or VS Code. Here’s a simple example:

      1. Open your text editor and type the following code:
      <!DOCTYPE html>
      <html>
      <head>
        <title>HTML Tutorial</title>
      </head>
      <body>
        <h1>Example Number 1</h1>
        <p>Hello, world!</p>
      </body>
      </html>
      
      ログイン後にコピー
      1. Save the file with a .html extension (e.g., index.html)
      2. Open the file in your web browser to see your first HTML webpage in action!
      3. To inspect your code, press Ctrl + Shift + C in Google Chrome to open the Developer Tools and explore the DOM structure.
      4. Go to the network tab in the Developer Tools and refresh your browser tab.

      You can find that there is a request in the name that you have saved as in this picture.
      Develop yourself to build Web UIs: Part  Understanding HTML

      In the response tab, you will find the code that you have written as in the following picture
      Develop yourself to build Web UIs: Part  Understanding HTML

      Now, what happened is that, once you opened the file you have saved as html, the computer began running the file in browser. The browser wanted something to show, so it made a request call to the file from which it was launched. The file gave the browser your code and that was found in the response section. Since it was a html file, the browser begins reading the HTML code from the top to the bottom. This process is known as parsing. During parsing, the browser encounters different HTML tags (like , , , etc.) and starts to build a structure called DOM based on these tags. As the browser builds the DOM, it simultaneously renders the content on your screen.


      Creating a Table

      Let’s take a step further by creating a simple table in HTML:

      1. Open the same HTML file and add the following code inside the tag:
      <p>Table Example</p>
      <table>
        <tr>
          <th>Name</th>
          <th>Power</th>
          <th>Is Kurama Present</th>
        </tr>
        <tr>
          <td>Naruto</td>
          <td>Rasengan</td>
          <td>Yes</td>
        </tr>
        <tr>
          <td>Sasuke</td>
          <td>Sharingan</td>
          <td>No</td>
        </tr>
      </table>
      
      ログイン後にコピー
      1. Save the file and refresh your browser to see the table displayed.

      Notice the heading is being rendered by paragraph tag. Alternatively, you can also use tag, which will center the heading of the table. Experiment with the caption tag and refresh to see the changes.

      Note that tag should only be used immediately after the

      opening tag.

      You’ve now successfully created a basic table in HTML. Feel free to experiment with additional rows and columns to get more comfortable with HTML syntax.


      Conclusion

      Congratulations on completing your first steps into web development with HTML! The key to mastering HTML is practice. Experiment with different elements, create your own webpages, and don’t be afraid to make mistakes — every error is a learning opportunity.

      Remember, this is just the beginning. As you continue to build on this foundation, you’ll soon be able to create more complex and dynamic websites. Let’s make the web a better place, one line of code at a time.

      この記事は、IT と機械工学の両方の経験を持つ専門家である Anantha Krishnan によって書かれています。フルスタック開発の経歴と機械および電気システムへの情熱を持つ Anantha Krishnan は、現在、専門分野の初心者を支援する教育コンテンツの作成に注力しています。

      以上がWeb UI を構築できるように自分自身を開発する: パート HTML を理解するの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

      ソース:dev.to
      このウェブサイトの声明
      この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
      人気のチュートリアル
      詳細>
      最新のダウンロード
      詳細>
      ウェブエフェクト
      公式サイト
      サイト素材
      フロントエンドテンプレート
      私たちについて 免責事項 Sitemap
      PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!