1. Embed images
The img element allows us to embed images in HTML documents. The image is not loaded until the HTML markup has been processed! ! The
src attribute specifies the URL of the image to be embedded; the
alt attribute defines the alternative content of the img element (rendered when the image cannot be displayed).
The width and height attributes specify the size (in pixels) of the image represented by the img element. If this attribute is omitted, the browser does not know how much screen space to allow for the image. The result is that the browser must rely on the image file itself to determine its size and then relocate the on-screen content to accommodate it, resulting in Shake.
1. Embed images in hyperlinks
Example: Use img and a elements to create a server-side partitioned response graph
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>使用img和a元素创建服务器端的分区响应图</title></head><body><a href="otherpage.html"> <img src="/static/imghwm/default1.png" data-src="../images/sport.jpg" class="lazy" ismap alt="奥运会运动项目" style="max-width:90%" height="131px"></a></body></html>
http://localhost:63342/html_test/public/embeddedContent_Chapter15/otherpage.html?466,39
Adding the ismap attribute creates a server-side partition response graph, and the URL address will contain the coordinates of the mouse click.
2. Create a client-side partition response graph
Create a client-side partition response graph and let the browser navigate to different URLs by clicking on different areas on an image.
The map element contains one or more area elements, each of which represents a clickable area on the image.
The attributes of the area element can be divided into two categories: the first category deals with the URL that the browser will navigate to after the image area represented by the area is clicked by the user; the second category Contains shape and coords attributes to indicate various image areas that the user can click.
Table area element attributes related to the target address
Attribute | Description |
---|---|
href | The URL that the browser should load when this area is clicked |
alt | Alternate content |
target | The browsing context that should be used to display the URL |
rel | Describes the relationship between the current document and the target document |
meida | Media applicable to this area |
hreflang | The language of the target document |
type | The MIME type of the target document |
The values of table shape and coords attributes
Attributes | coords value properties and meaning |
---|---|
rect | represents a rectangular area. The coords attribute must consist of four comma-separated integers (left, top, right, bottom) |
circle | represents a circular area. The coords attribute must consist of three integers separated by commas (the distance from the left edge to the center of the circle, the distance from the upper edge to the center of the circle, and the radius) |
poly | represents a polygon. The coords attribute must contain at least six integers separated by commas (each number represents a vertex of the polygon) |
default | The default area, which covers the entire sheet Picture |
Example: Creating a Partitioned Response Graph
<p> <img src="/static/imghwm/default1.png" data-src="../images/sport.jpg" class="lazy" usemap="#sportmap" alt="Sport image"></p><map name="sportmap"> <area href="archery.html" shape="rect" coords="0,5,90,125" alt="射箭"> <area href="swimming.html" shape="rect" coords="120,5,250,125" alt="游泳"> <area href="weightlifting.html" shape="rect" coords="290,5,390,125" alt="举重"> <area href="hockey.html" shape="rect" coords="420,5,520,125" alt="曲棍球"> <area href="sport.html" shape="default" alt="运动"></map>
Note:
1. Add the usemap attribute to the img element; associate it with the map element.
2. There is no need to use the a element to display hyperlinks.
2. Embedding an HTML document
The iframe element allows us to embed another document in an existing HTML document.
Example: Using iframe elements
<header> <nav> <ul> <li> <a href="img_a.html" target="myframe">Img a Demo</a> </li> <li> <a href="img_map.html" target="myframe">Img map Demo</a> </li> </ul> </nav></header><iframe name="myframe" width="300" height="100"></iframe>
In the above example, an iframe element with the name attribute myframe is created, thus creating an iframe element with the name is the browsing context of myframe. This browsing context is then used in conjunction with the target attribute of other elements (specifically a, form, button, input, and base). In the example, the URL specified in the href attribute will be loaded into the iframe.
Other attributes of the table
Attributes | Description |
---|---|
src | Specify the URL that the iframe should load and display at the beginning |
srcdoc | Define a URL for inlining Displayed HTML document |
seamless | Display iframe content as if it were an integral part of the main HTML document (not supported by the browser) |
sandbox | Restrict HTML documents (not supported by the browser) |
三、 通过插件嵌入内容
object和embed元素最初都是作为扩展浏览器能力的一种方式,用于添加插件支持,而插件能够处理浏览器不直接支持的内容。
示例:嵌入视频
<embed src="https://www.youtube.com/embed/jItLiNKSCBg" width="560" height="349" allowfullscreen="true"><object data="https://www.youtube.com/embed/jItLiNKSCBg" width="560" height="349"> <param name="allowFullScreen" value="true"> <b>Sorry!</b>We can't display this content</object>
示例:用object元素嵌入一张图像
<object data="../images/sport.jpg" type="image/jpg"></object>
示例:用object元素创建一张客户端分区响应图
<header> <nav> <ul> <li> <a href="img_a.html" target="myframe">Img a Demo</a> </li> <li> <a href="img_map.html" target="myframe">Img map Demo</a> </li> </ul> </nav></header><object type="text/html" name="myframe" width="300" height="100"></object>
注意:chrome和Safari目前不支持用object元素创建客户端分区响应图
示例:用object元素创建浏览器上下文
<p> <object type="image/jpg" data="../images/sport.jpg" usemap="#sportmap"></object></p><map name="sportmap"> <area href="archery.html" shape="rect" coords="0,5,90,125" alt="射箭"> <area href="swimming.html" shape="rect" coords="120,5,250,125" alt="游泳"> <area href="weightlifting.html" shape="rect" coords="290,5,390,125" alt="举重"> <area href="hockey.html" shape="rect" coords="420,5,520,125" alt="曲棍球"> <area href="sport.html" shape="default" alt="运动"></map>
四、嵌入数字表现形式
1. 显示进度
progress元素可以用来表现某项任务逐渐完成的过程。
value属性定义了当前的进度,它位于0和max属性的值所构成的范围之间。当max属性被省略时,范围是0至1。
示例:使用progress元素
<progress id="myprogress" value="10" max="100"></progress><p> <button type="button" value="30">30%</button> <button type="button" value="60">60%</button> <button type="button" value="90">90%</button></p><script> var buttons = document.getElementsByTagName("button"); var progress = document.getElementsByTagName("progress")[0]; for(var i = 0, len = buttons.length; i < len; i++){ buttons[i].onclick = function(e){ progress.value = e.target.value; // 千万不能通过 buttons[i].value 获取值 } }</script>
2. 显示范围里的值
meter元素显示了某个范围内所有可能值中的一个。
min和max属性设定了可能值所处范围的边界,它们可以用浮点数表示。
meter元素的显示可以分为三个部分:过低、过高和最佳。
low属性设置一个值,在它之下的所有值都被认为是过低;
high属性设置一个值,在它之上的所有值都被认为是过高;
optimum属性则指定了“最佳”的值。
<meter id="mymeter" value="90" min="0" max="100" low="40" high="80" optimum="60"></meter><p> <button type="button" value="30">30</button> <button type="button" value="60">60</button> <button type="button" value="90">90</button></p><script> var buttons = document.getElementsByTagName("button"); var meter = document.getElementById("mymeter"); for(var i = 0, len = buttons.length; i < len; i++){ buttons[i].onclick = function(e){ meter.value = e.target.value; } }</script>
The above is the detailed content of HTML5 - A closer look at embedded content. For more information, please follow other related articles on the PHP Chinese website!

There is no difference between HTML5 and H5, which is the abbreviation of HTML5. 1.HTML5 is the fifth version of HTML, which enhances the multimedia and interactive functions of web pages. 2.H5 is often used to refer to HTML5-based mobile web pages or applications, and is suitable for various mobile devices.

HTML5 is the latest version of the Hypertext Markup Language, standardized by W3C. HTML5 introduces new semantic tags, multimedia support and form enhancements, improving web structure, user experience and SEO effects. HTML5 introduces new semantic tags, such as, ,, etc., to make the web page structure clearer and the SEO effect better. HTML5 supports multimedia elements and no third-party plug-ins are required, improving user experience and loading speed. HTML5 enhances form functions and introduces new input types such as, etc., which improves user experience and form verification efficiency.

How to write clean and efficient HTML5 code? The answer is to avoid common mistakes by semanticizing tags, structured code, performance optimization and avoiding common mistakes. 1. Use semantic tags such as, etc. to improve code readability and SEO effect. 2. Keep the code structured and readable, using appropriate indentation and comments. 3. Optimize performance by reducing unnecessary tags, using CDN and compressing code. 4. Avoid common mistakes, such as the tag not closed, and ensure the validity of the code.

H5 improves web user experience with multimedia support, offline storage and performance optimization. 1) Multimedia support: H5 and elements simplify development and improve user experience. 2) Offline storage: WebStorage and IndexedDB allow offline use to improve the experience. 3) Performance optimization: WebWorkers and elements optimize performance to reduce bandwidth consumption.

HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.

HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.