搜索
首页web前端js教程自行开发构建 Web UI:部分了解 HTML

Web 开发是当今最受欢迎的技能之一。它涉及创建可通过浏览器访问的用户友好且引人入胜的网站。成为 Web 开发人员的第一步是了解 HTML。

Develop yourself to build Web UIs: Part  Understanding HTML

HTML超文本标记语言)是任何网页的支柱。它是用于构建网页的标准语言,决定内容在浏览器中的显示方式。虽然页面的外观由 CSS (层叠样式表) 决定,其功能由 JS (Javascript) 决定,HTML 负责基本骨架或结构。

在深入学习这部分课程之前,了解您的旅程中将使用的著名和反复出现的术语非常重要。这些将帮助您随着我们的进展理解概念(也让作者更容易解释事情;-))。


了解行话

  1. 编程语言:以计算机可以执行的特定语法(编程语言的方式)编写的一组指令。请记住,计算机只能理解二进制代码(1 或 0),现在,为了使计算机理解逻辑并找到权衡,我们(人类)创建了一种编程语言,以便可以轻松地我们编码,也让计算机理解它。
  2. 编译器:将用编程语言编写的代码翻译成计算机可以理解和执行的机器语言的工具。
  3. 语法:定义编程语言结构的规则。将其视为句子中单词的排列方式以使其有意义。
  4. 注释:代码中的注释,解释代码某些部分的作用。注释可以帮助其他开发人员(或未来的你)理解代码背后的逻辑。
  5. DOM(文档对象模型):DOM 是 HTML 文档的树状表示。 HTML 中的每个标签都成为该树中的一个节点。例如,如果您的 HTML 有一个 带有

    的标签(paragraph) 在其中,浏览器创建一个主体节点,并以段落节点作为其子节点。

  6. 孩子们:随着你的进步,你就会明白这一点。元素嵌套在另一个元素内。例如,在 HTML 中,div 标签 (
    ) 内的段落标签 (

    ) 将被视为 div 的子级。

  7. 块级元素:随着您的进步,您将了解这个术语。该术语通常描述元素的特征,即它将占据全部可用宽度。

  8. 使用 HTML 启动

    HTML 代表 超文本标记语言

    • 超文本:指 HTML 将不同文档链接在一起的能力。

    • 标记语言:使用标签来注释文本,定义文本在浏览器中的显示方式。

    这是 HTML 文档的基本结构:

    
      
        <title>HTML Tutorial</title>
      
      
        <p>Hello, world!</p>
      
    
    
    • 标签:在 HTML 中,标签用于定义元素。标签括在尖括号中,例如 或

    • 元素:由开始标签和结束标签组成,其中可能包含内容。例如,

      你好,世界!

      是一个段落元素。

    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:
        
        
          <title>HTML Tutorial</title>
        
        
          <h1 id="Example-Number">Example Number 1</h1>
          <p>Hello, world!</p>
        
        
        
        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>
        
        Name Power Is Kurama Present
        Naruto Rasengan Yes
        Sasuke Sharingan No
        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.

        本文由 Anantha Krishnan 撰写,他是一位在 IT 和机械工程领域拥有丰富经验的专业人士。拥有全栈开发背景以及对机械和电气系统的热情,Anantha Krishnan 现在专注于创建教育内容,以帮助其专业领域的初学者。

      以上是自行开发构建 Web UI:部分了解 HTML的详细内容。更多信息请关注PHP中文网其他相关文章!

      声明
      本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
      JavaScript:探索网络语言的多功能性JavaScript:探索网络语言的多功能性Apr 11, 2025 am 12:01 AM

      JavaScript是现代Web开发的核心语言,因其多样性和灵活性而广泛应用。1)前端开发:通过DOM操作和现代框架(如React、Vue.js、Angular)构建动态网页和单页面应用。2)服务器端开发:Node.js利用非阻塞I/O模型处理高并发和实时应用。3)移动和桌面应用开发:通过ReactNative和Electron实现跨平台开发,提高开发效率。

      JavaScript的演变:当前的趋势和未来前景JavaScript的演变:当前的趋势和未来前景Apr 10, 2025 am 09:33 AM

      JavaScript的最新趋势包括TypeScript的崛起、现代框架和库的流行以及WebAssembly的应用。未来前景涵盖更强大的类型系统、服务器端JavaScript的发展、人工智能和机器学习的扩展以及物联网和边缘计算的潜力。

      神秘的JavaScript:它的作用以及为什么重要神秘的JavaScript:它的作用以及为什么重要Apr 09, 2025 am 12:07 AM

      JavaScript是现代Web开发的基石,它的主要功能包括事件驱动编程、动态内容生成和异步编程。1)事件驱动编程允许网页根据用户操作动态变化。2)动态内容生成使得页面内容可以根据条件调整。3)异步编程确保用户界面不被阻塞。JavaScript广泛应用于网页交互、单页面应用和服务器端开发,极大地提升了用户体验和跨平台开发的灵活性。

      Python还是JavaScript更好?Python还是JavaScript更好?Apr 06, 2025 am 12:14 AM

      Python更适合数据科学和机器学习,JavaScript更适合前端和全栈开发。 1.Python以简洁语法和丰富库生态着称,适用于数据分析和Web开发。 2.JavaScript是前端开发核心,Node.js支持服务器端编程,适用于全栈开发。

      如何安装JavaScript?如何安装JavaScript?Apr 05, 2025 am 12:16 AM

      JavaScript不需要安装,因为它已内置于现代浏览器中。你只需文本编辑器和浏览器即可开始使用。1)在浏览器环境中,通过标签嵌入HTML文件中运行。2)在Node.js环境中,下载并安装Node.js后,通过命令行运行JavaScript文件。

      在Quartz中如何在任务开始前发送通知?在Quartz中如何在任务开始前发送通知?Apr 04, 2025 pm 09:24 PM

      如何在Quartz中提前发送任务通知在使用Quartz定时器进行任务调度时,任务的执行时间是由cron表达式设定的。现�...

      在JavaScript中,如何在构造函数中获取原型链上函数的参数?在JavaScript中,如何在构造函数中获取原型链上函数的参数?Apr 04, 2025 pm 09:21 PM

      在JavaScript中如何获取原型链上函数的参数在JavaScript编程中,理解和操作原型链上的函数参数是常见且重要的任�...

      微信小程序webview中Vue.js动态style位移失效是什么原因?微信小程序webview中Vue.js动态style位移失效是什么原因?Apr 04, 2025 pm 09:18 PM

      在微信小程序web-view中使用Vue.js动态style位移失效的原因分析在使用Vue.js...

      See all articles

      热AI工具

      Undresser.AI Undress

      Undresser.AI Undress

      人工智能驱动的应用程序,用于创建逼真的裸体照片

      AI Clothes Remover

      AI Clothes Remover

      用于从照片中去除衣服的在线人工智能工具。

      Undress AI Tool

      Undress AI Tool

      免费脱衣服图片

      Clothoff.io

      Clothoff.io

      AI脱衣机

      AI Hentai Generator

      AI Hentai Generator

      免费生成ai无尽的。

      热门文章

      R.E.P.O.能量晶体解释及其做什么(黄色晶体)
      3 周前By尊渡假赌尊渡假赌尊渡假赌
      R.E.P.O.最佳图形设置
      3 周前By尊渡假赌尊渡假赌尊渡假赌
      R.E.P.O.如果您听不到任何人,如何修复音频
      3 周前By尊渡假赌尊渡假赌尊渡假赌
      WWE 2K25:如何解锁Myrise中的所有内容
      3 周前By尊渡假赌尊渡假赌尊渡假赌

      热工具

      ZendStudio 13.5.1 Mac

      ZendStudio 13.5.1 Mac

      功能强大的PHP集成开发环境

      Atom编辑器mac版下载

      Atom编辑器mac版下载

      最流行的的开源编辑器

      安全考试浏览器

      安全考试浏览器

      Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

      SublimeText3 Linux新版

      SublimeText3 Linux新版

      SublimeText3 Linux最新版

      SublimeText3汉化版

      SublimeText3汉化版

      中文版,非常好用