📜  Jawaban 1 - Html (1)

📅  最后修改于: 2023-12-03 15:16:38.821000             🧑  作者: Mango

Jawaban 1 - HTML

HTML is the standard markup language used to create web pages. It is the foundation of every website and plays a crucial role in defining the structure and content of a web page. HTML stands for HyperText Markup Language and is used in conjunction with other technologies like CSS and JavaScript to create visually appealing and interactive web pages.

Basics of HTML

HTML is a text-based language and is easy to understand and use. It uses tags and attributes to define the structure and format of a web page. Here are some basic tags that are used in HTML:

  • <html>: Defines the root of an HTML document.
  • <head>: Contains meta information about the document, such as title and links to external stylesheets and scripts.
  • <body>: Contains the main content of the web page.
  • <h1> to <h6>: Defines headings of different sizes.
  • <p>: Defines a paragraph of text.

Here's an example of a basic HTML document:

<!DOCTYPE html>
<html>
  <head>
    <title>My Web Page</title>
  </head>
  <body>
    <h1>Welcome to my web page</h1>
    <p>This is some sample text.</p>
  </body>
</html>
Attributes in HTML

Attributes are used to provide additional information about HTML elements. They are specified inside the opening tag of the element and take the form of attribute="value". Here are some commonly used attributes:

  • id: Specifies a unique identifier for an element.
  • class: Specifies one or more classes for an element.
  • href: Specifies the link destination for an anchor tag (<a>).
  • src: Specifies the URL of an image or other media element.
  • alt: Specifies alternative text for an image.

Here's an example of how to use attributes in HTML:

<!DOCTYPE html>
<html>
  <head>
    <title>My Web Page</title>
  </head>
  <body>
    <h1 id="main-heading" class="main-heading">Welcome to my web page</h1>
    <p>This is some <a href="https://www.example.com">sample text</a>.</p>
    <img src="image.jpg" alt="An image">
  </body>
</html>
Using CSS with HTML

CSS is used to style HTML elements and make them look visually appealing. It stands for Cascading Style Sheets and provides a way to separate the presentation of a web page from its content. CSS is typically stored in external files or included within the HTML document using the <style> tag.

Here's an example of using CSS to style an HTML element:

<!DOCTYPE html>
<html>
  <head>
    <title>My Web Page</title>
    <style>
      .main-heading {
        font-size: 2rem;
        color: blue;
      }
    </style>
  </head>
  <body>
    <h1 class="main-heading">Welcome to my web page</h1>
    <p>This is some sample text.</p>
  </body>
</html>
Conclusion

HTML is an essential technology for creating websites. With a solid understanding of HTML, web developers can create websites that are optimized for search engines, accessible to all users, and visually appealing.