Home Web Front-end Front-end Q&A How to make html web page

How to make html web page

May 27, 2023 am 11:41 AM

1. What is HTML?

HTML (Hyper Text Markup Language), that is, hypertext markup language. Simply put, it is the basic language for web page production. It is a markup language that describes web pages through markup. Each web page may be composed of multiple web page elements (such as text, images, videos, audio, etc.). The main function of HTML is to organize the text, images, audio, video and other content and format information input by the user to form a web page document, which is parsed and rendered by the browser and finally presented to the user.

2. HTML tags

HTML tags are the core concept of HTML. They are commands wrapped in angle brackets that tell the browser how to display text. HTML tags include a start tag (e.g. <head>), an end tag (e.g. </head>), or a single tag (e.g. <img> ).

When writing HTML, you must follow the following rules:

  1. All HTML elements must be within the opening tag <tag> and the closing tag &lt ;/tag> is closed. For a single tag, you can use the self-closing tag <tag />. The
  2. <html> tag is the root tag, indicating the beginning of the entire HTML document. The <html> tag must be included in all HTML elements.
  3. Each HTML page needs to contain <head> and <body> tags. <head>The tag contains the metadata of the document, such as the document's title, keywords, etc. <body> tag contains visible page content, such as text, images, etc.
  4. In HTML, tags and attributes are not case-sensitive, but it is recommended to use lowercase letters to enhance the readability of the code.

The following is an example of an HTML template:

<!DOCTYPE html> 
<html>
  <head>
    <title>标题</title>
  </head>
  <body>
    <h1>标题 1</h1>
    <p>这是一个段落。</p>
  </body>
</html>
Copy after login

3. CSS

CSS (Cascading Style Sheets) is a description of web page styles and The language of layout. It is used along with HTML to create beautiful web pages. CSS controls aspects of web page display such as fonts, colors, backgrounds, borders, and layout.

There are two ways to embed CSS styles in HTML: internal styles and external styles.

Internal style is to add CSS code style in the <head> tag of the page code, for example:

<!DOCTYPE html> 
<html>
  <head>
    <title>标题</title>
    <style>
      h1 {
        color: blue;
        font-family: Arial;
      }
    </style>
  </head>
  <body>
    <h1>标题 1</h1>
    <p>这是一个段落。</p>
  </body>
</html>
Copy after login

External style sheet is to add style rules to external files For example:

In the style file style.css:

h1 {
  color: blue;
  font-family: Arial;
}
Copy after login

Add external style to the HTML page:

<!DOCTYPE html> 
<html>
  <head>
    <title>标题</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <h1>标题 1</h1>
    <p>这是一个段落。</p>
  </body>
</html>
Copy after login

4. JavaScript

JavaScript It is a scripting language used to control HTML content and make web pages interactive and dynamic. It can be used for interaction with users, such as form validation, image switching, dynamically updating pages, etc.

There are two ways to embed JavaScript in HTML pages: internal scripts and external scripts.

Internal script is to add JavaScript code in <head> or <body> of the page code, for example:

<!DOCTYPE html> 
<html>
  <head>
    <title>标题</title>
    <script>
      function sayHello() {
        alert("Hello!");
      }
    </script>
  </head>
  <body>
    <button onclick="sayHello()">点击这里</button>
  </body>
</html>
Copy after login

External script It is to add the script code to the external file, for example:

In the script file script.js:

function sayHello() {
  alert("Hello!");
}
Copy after login

Add the external script to the HTML page:

<!DOCTYPE html> 
<html>
  <head>
    <title>标题</title>
    <script src="script.js"></script>
  </head>
  <body>
    <button onclick="sayHello()">点击这里</button>
  </body>
</html>
Copy after login

5. Make an HTML page

The following are the steps to make a simple HTML page:

  1. Open a text editor, such as Notepad or Sublime Text.
  2. Create a new text file and save it in the .html file format.
  3. Write HTML code, including document type declaration, HTML element tags and content.
  4. Add CSS styles to control the appearance and style of your web pages.
  5. Add JavaScript scripts to control the interactivity and dynamics of web pages.
  6. Open the HTML file with a browser to preview and test the page.

For example, the following is an example of an HTML page containing CSS and JavaScript:

<!DOCTYPE html> 
<html>
  <head>
    <title>我的HTML页面</title>
    <style>
      body {
        background-color: #f2f2f2;
        font-family: Arial;
      }
      h1 {
        color: #009900;
        font-size: 36px;
        text-align: center;
        margin-top: 50px;
      }
    </style>
    <script>
      function sayHello() {
        alert("Hello!");
      }
    </script>
  </head>
  <body>
    <h1>欢迎访问我的HTML页面</h1>
    <button onclick="sayHello()">点击这里</button>
  </body>
</html>
Copy after login

6. Summary

HTML is the basic language for web page production. Use To describe and present web content. CSS and JavaScript can enhance the appearance and interactivity of web pages, making them more attractive. Making an HTML page requires following the rules of HTML tags, adding styles and scripts, and finally testing it in the browser. By learning HTML, CSS and JavaScript, you can gain basic knowledge of front-end development and lay a solid foundation for web design and development.

The above is the detailed content of How to make html web page. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1245
24
Frontend Development with React: Advantages and Techniques Frontend Development with React: Advantages and Techniques Apr 17, 2025 am 12:25 AM

The advantages of React are its flexibility and efficiency, which are reflected in: 1) Component-based design improves code reusability; 2) Virtual DOM technology optimizes performance, especially when handling large amounts of data updates; 3) The rich ecosystem provides a large number of third-party libraries and tools. By understanding how React works and uses examples, you can master its core concepts and best practices to build an efficient, maintainable user interface.

React's Ecosystem: Libraries, Tools, and Best Practices React's Ecosystem: Libraries, Tools, and Best Practices Apr 18, 2025 am 12:23 AM

The React ecosystem includes state management libraries (such as Redux), routing libraries (such as ReactRouter), UI component libraries (such as Material-UI), testing tools (such as Jest), and building tools (such as Webpack). These tools work together to help developers develop and maintain applications efficiently, improve code quality and development efficiency.

React and the Frontend: Building Interactive Experiences React and the Frontend: Building Interactive Experiences Apr 11, 2025 am 12:02 AM

React is the preferred tool for building interactive front-end experiences. 1) React simplifies UI development through componentization and virtual DOM. 2) Components are divided into function components and class components. Function components are simpler and class components provide more life cycle methods. 3) The working principle of React relies on virtual DOM and reconciliation algorithm to improve performance. 4) State management uses useState or this.state, and life cycle methods such as componentDidMount are used for specific logic. 5) Basic usage includes creating components and managing state, and advanced usage involves custom hooks and performance optimization. 6) Common errors include improper status updates and performance issues, debugging skills include using ReactDevTools and Excellent

The Future of React: Trends and Innovations in Web Development The Future of React: Trends and Innovations in Web Development Apr 19, 2025 am 12:22 AM

React's future will focus on the ultimate in component development, performance optimization and deep integration with other technology stacks. 1) React will further simplify the creation and management of components and promote the ultimate in component development. 2) Performance optimization will become the focus, especially in large applications. 3) React will be deeply integrated with technologies such as GraphQL and TypeScript to improve the development experience.

React vs. Backend Frameworks: A Comparison React vs. Backend Frameworks: A Comparison Apr 13, 2025 am 12:06 AM

React is a front-end framework for building user interfaces; a back-end framework is used to build server-side applications. React provides componentized and efficient UI updates, and the backend framework provides a complete backend service solution. When choosing a technology stack, project requirements, team skills, and scalability should be considered.

React: The Power of a JavaScript Library for Web Development React: The Power of a JavaScript Library for Web Development Apr 18, 2025 am 12:25 AM

React is a JavaScript library developed by Meta for building user interfaces, with its core being component development and virtual DOM technology. 1. Component and state management: React manages state through components (functions or classes) and Hooks (such as useState), improving code reusability and maintenance. 2. Virtual DOM and performance optimization: Through virtual DOM, React efficiently updates the real DOM to improve performance. 3. Life cycle and Hooks: Hooks (such as useEffect) allow function components to manage life cycles and perform side-effect operations. 4. Usage example: From basic HelloWorld components to advanced global state management (useContext and

Understanding React's Primary Function: The Frontend Perspective Understanding React's Primary Function: The Frontend Perspective Apr 18, 2025 am 12:15 AM

React's main functions include componentized thinking, state management and virtual DOM. 1) The idea of ​​componentization allows splitting the UI into reusable parts to improve code readability and maintainability. 2) State management manages dynamic data through state and props, and changes trigger UI updates. 3) Virtual DOM optimization performance, update the UI through the calculation of the minimum operation of DOM replica in memory.

React and Frontend Development: A Comprehensive Overview React and Frontend Development: A Comprehensive Overview Apr 18, 2025 am 12:23 AM

React is a JavaScript library developed by Facebook for building user interfaces. 1. It adopts componentized and virtual DOM technology to improve the efficiency and performance of UI development. 2. The core concepts of React include componentization, state management (such as useState and useEffect) and the working principle of virtual DOM. 3. In practical applications, React supports from basic component rendering to advanced asynchronous data processing. 4. Common errors such as forgetting to add key attributes or incorrect status updates can be debugged through ReactDevTools and logs. 5. Performance optimization and best practices include using React.memo, code segmentation and keeping code readable and maintaining dependability

See all articles