search
HomeWeb Front-endH5 TutorialSharing several page examples of HTML5 design and modification_html5 tutorial skills

To understand and become familiar with the new semantic elements in HTML5, the best way is to take a classic HTML document as an example, and then enrich it with some fresh nutrients of HTML5. The following is the page we want to transform. The page is very simple and contains only one article.

ApocalypsePage_Original.html, this is a page with a very standardized format, and all styles come from external style sheets.

XML/HTML CodeCopy content to clipboard
  1. html>  
  2. html lang="zh-CN">  
  3. head>  
  4.   meta charset="utf-8">  
  5.   title>Apocalypse Nowtitle>  
  6.   link rel="stylesheet" href="ApocalypsePage_Original.css">  
  7. head>  
  8.   
  9. body>  
  10. div class="Header">  
  11.   h1>How the World Could Endh1>  
  12.   p class="Teaser">Scenarios that spell the end of life as we knowp>  
  13.   p class="Byline">by Ray N. Carnationp>  
  14. div>  
  15.   
  16. div class="Content">  
  17.   p>span class="LeadIn">Right nowspan>, you're probably feeling pretty good. After all, life in the developed world is comfortablespan class="style1">span>probably more comfortable than it's been for the average human being throughout all of recorded history.p>  
  18.   p>But don't get too smug. There's still plenty of horrific ways it could all fall apart. In this article, you'll learn about a few of our favorites.p>  
  19.      
  20.   h2>Mayan Doomsdayh2>  
  21.   p>Skeptics suggest that the Mayan calendar simply rolls to a new 5,126-year era after 2012, and doesn't actually predict a life-ending apocalypse. But given that the long-dead Mayans were wrong about virtually everything else, why should we trust them on this?p>  
  22.      
  23.   h2>Robot Takeoverh2>  
  24.   p>Not quite as frightening as a Vampire Takeover or Living-Dead Takeover, a robot rebellion is still a disquieting thought. We are already outnumbered by our technological gadgets, and even Bill Gates fears the day his Japanese robot slave turns him over by the ankles and asks (in a suitably robotic voice) "Who's your daddy now?"p>  
  25.      
  26.   h2>Unexplained Singularityh2>  
  27.   p>We don't know how the universe started, so we can't be sure it won't just end, maybe today, and maybe with nothing more exciting than a puff of anti-matter and a slight fizzing noise.p>  
  28.      
  29.   h2>Runaway Climate Changeh2>  
  30.   p>Dismissed by some, Al Gore's prophecy of doom may still come true. If it does, we may have to contend with vicious storms, widespread food shortages, and surly air conditioning repairmen.p>  
  31.      
  32.   h2>Global Epidemich2>  
  33.   p>Some time in the future, a lethal virus could strike. Predictions differ about the source of the disease, but candidates include monkeys in the African jungle, bioterrorists, birds and pigs with the flu, warriors from the future, an alien race, hospitals that use too many antibiotics, vampires, the CIA, and unwashed brussel sprouts. Whatever the source, it's clearly bad news.p>  
  34.   
  35. div>  
  36.   
  37. div class="Footer">  
  38.   p class="Disclaimer">These apocalyptic predictions do not reflect the views of the author.p>  
  39.   p>  
  40.     a href="AboutUs.html">About Usa>  
  41.     a href="Disclaimer.html">Disclaimera>  
  42.     a href="ContactUs.html">Contact Usa>  
  43.   p>  
  44.   p>Copyright © 2014p>  
  45. div>  
  46. body>  
  47. html>  

在不增加任何 CSS 样式表之前,效果如下:

上面通过三个

将页面分成了三个部分,顶部的页眉,中部的内容和底部的页脚。

这个例子中的样式表很简单,整个页面最大宽度设置为 800 像素,避免文本在宽屏显示器上显示过长。页眉位于一个带有蓝色边框的盒子中,内容区的两侧都增加了内边距,而页脚在整个页面的底部居中。

ApocalypsePage_Original.css样式文件内容如下:

XML/HTML Code复制内容到剪贴板
  1. @charset "utf-8";
  2. /* CSS Document */
  3. body{
  4. /*font-family To use safe fonts, follow the principle of special first and then general,
  5. First give the font you want, then a safer font,
  6. Finally ends with sans-serif font*/
  7. font-family: "Lucida sans Unicode", "Lucida Grande", Geneva, sans-serif;
  8. max-width: 800px; /*The maximum width does not exceed 800 pixels*/
  9. }
  10. /*Title area style at the top of the page*/
  11. .Header {
  12. background-color: #7695FE; /*Any color value is acceptable*/
  13. border: thin #336699 solid; /*all-in-one border attribute*/
  14. padding: 10px; /* 10 pixel padding, the distance between the border and the content*/
  15. margin: 10px; /* 10 pixel margin, the distance between the border and surrounding elements*/
  16. text-align: center; /*Header text is centered*/
  17. }
  18. /*Title in headerh1>Style*/
  19. .Header h1{
  20. margin: 0px;
  21. color: white;
  22. font-size: xx-large; /*Precise control can be done in pixels or em units*/
  23. }
  24. /*Header subtitle style*/
  25. .Header .Teaser{
  26. margin: 0px;
  27. font-weight: bold;
  28. }
  29. /*Signature line style in header*/
  30. .Header .Byline{
  31. font-style: italic;
  32. font-size: small;
  33. margin: 0px;
  34. }
  35. .Content{
  36. font-size: medium;
  37. font-family: Cambria, Cochin, Georgia, "Times New Roman", Times, serif;
  38. /*Maximum left and right padding*/
  39. padding-top: 20px;
  40. padding-right: 50px;
  41. padding-bottom: 5px;
  42. padding-left: 50px;
  43. line-height: 120%; /*The distance between two adjacent text lines*/
  44. }
  45. .Content .LeadIn{
  46. font-weight: bold;
  47. font-size: large;
  48. font-variant: small-caps;
  49. }
  50. .Content .h2{
  51. color: #24486C;
  52. margin-bottom: 2px;
  53. font-size: medium;
  54. }
  55. .Content p{
  56. margin-top: 0px;
  57. }
  58. .Footer{
  59. text-align: center;
  60. font-size: x-small;
  61. }
  62. .Footer .Disclaimer{
  63. font-style: italic;
  64. }
  65. .Footer p{
  66. margin: 3px;
  67. }

In this way, our style sheet has been bent. Now let’s see what the result will be? As shown below:

Use HTML5 to construct the page

Still a must-have element in web design, it is an intuitive, versatile container that allows you to apply styles to any block on the page. But the problem with
is that it itself doesn't reflect any information about the page.

To improve this situation with HTML5, replace

with an element with more descriptive semantics.

In ApocalypsePage_Revised.html, the class attributes of Header and Footer and

have been replaced by
and
. Part of the code is as follows:
XML/HTML CodeCopy content to clipboard
  1. header>  
  2.   h1>How the World Could Endh1>  
  3.   p class="Teaser">Scenarios that spell the end of life as we knowp>  
  4.   p class="Byline">by Ray N. Carnationp>  
  5. header>  
  6. ...   
  7. footer>  
  8.   p class="Disclaimer">These apocalyptic predictions do not reflect the views of the author.p>  
  9.   p>  
  10.     a href="AboutUs.html">About Usa>  
  11. ...   
  12.   p>  
  13.   p>Copyright © 2014p>  
  14. footer>  

当然,对应的 ApocalypsePage_Revised.css 文件也需要进行修改,将其中的 .Header 和 .Footer 替换为 header 和 footer 。部分代码如下:

XML/HTML Code复制内容到剪贴板
  1. /*Title area style at the top of the page*/
  2. header {
  3. background-color: #7695FE; /*Any color value is acceptable*/
  4. border: thin #336699 solid; /*all-in-one border attribute*/
  5. padding: 10px; /* 10 pixel padding, the distance between the border and the content*/
  6. margin: 10px; /* 10 pixel margin, the distance between the border and surrounding elements*/
  7. text-align: center; /*Header text is centered*/
  8. }
  9. /*Title in headerh1>Style*/
  10. header h1{
  11. margin: 0px;
  12. color: white;
  13. font-size: xx-large; /*Precise control can be done in pixels or em units*/
  14. }

Finally, there is one element that needs to be used in the sample file, which is the

element, which represents a complete, self-contained content.

The

element should contain the content of a news report or article, including the title, byline, and body text. So the structure after adding the

element is as follows:

XML/HTML CodeCopy content to clipboard
  1. article>  
  2.   header>  
  3.   h1>How the World Could Endh1>  
  4.   p class="Teaser">Scenarios that spell the end of life as we knowp>  
  5.   p class="Byline">by Ray N. Carnationp>  
  6.   header>  
  7.   div class="Content">  
  8.   p>span class="LeadIn">Right nowspan>, you're probably feeling pretty good. After all, life in the developed world is comfortablespan class="style1">span>probably more comfortable than it's been for the average human being throughout all of recorded history.p>  
  9. ...   
  10.   div>  
  11. article>  


重新设计后,页面结构如下:

添加插图

很多页面都是包含图片的。但是,插图 (figure) 与图片的概念还不完全一样。插图虽然独立于文本,但是文本中会提到它。

一般来说插图应该是浮动的,还会有浮动图题。下面是在文章中添加插图的 HTML 标记,在正文的第一段和第二段之间的位置,部分代码如下:

XML/HTML Code复制内容到剪贴板
  1. ...   
  2. div class="Content">  
  3. p>span class="LeadIn">Right nowspan>, you're ...p>  
  4. div class="FloatFigure">  
  5. img src="human_skull.jpg" alt="Human skull">  
  6. p>Will you be the last person standing if one of these apocalyptic   
  7. scenarios plays out?p>  
  8. div>  
  9. p>But don't get too smug. There's...p>  
  10. ...  


相应的 样式表规则如下:

XML/HTML Code复制内容到剪贴板
  1. .FloatFigure{   
  2.   float: left;   
  3.   margin: 0px 20px 0px 0px;   
  4. }   
  5. .FloatFigure p{   
  6.   max-width: 300px;   
  7.   font-size: small;   
  8.   font-style: italic;   
  9.   margin-bottom: 5px;   
  10. }  


下图展示了这个示例的外观,插图恰好在第一段文本之后,浮动在后面文本的左侧,图题的文本的宽度我们限制住了,让图题显示很充实、很优雅。

HTML5 中提供了一个

元素,图题可以放在
中的
元素里,经过改造,代码如下:

XML/HTML Code复制内容到剪贴板
  1. figure class="FloatFigure" >
  2. img src="human_skull. jpg" alt="Human skull">
  3. figcaption>Will you be the last person standing if one of these apocalyptic
  4. scenarios plays out?figcaption>
  5. figure>


Of course, the selector in the style sheet can be modified accordingly.

XML/HTML CodeCopy content to clipboard
  1. .FloatFigure{
  2. float: left;
  3. margin: 0px 20px 0px 0px;
  4. }
  5. .FloatFigure figcaption{
  6. max-width: 300px;
  7. font-size: small;
  8. font-style: italic;
  9. margin-bottom: 5px;
  10. }


Finally, the alt attribute in the Sharing several page examples of HTML5 design and modification_html5 tutorial skills element can be deleted, because the title contains a complete description of the image.

Add a note using

The new

The following example will be used as a pull quote. Use the

element to create this effect, but use the
Statement
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
Understanding H5: The Meaning and SignificanceUnderstanding H5: The Meaning and SignificanceMay 11, 2025 am 12:19 AM

H5 is HTML5, the fifth version of HTML. HTML5 improves the expressiveness and interactivity of web pages, introduces new features such as semantic tags, multimedia support, offline storage and Canvas drawing, and promotes the development of Web technology.

H5: Accessibility and Web Standards ComplianceH5: Accessibility and Web Standards ComplianceMay 10, 2025 am 12:21 AM

Accessibility and compliance with network standards are essential to the website. 1) Accessibility ensures that all users have equal access to the website, 2) Network standards follow to improve accessibility and consistency of the website, 3) Accessibility requires the use of semantic HTML, keyboard navigation, color contrast and alternative text, 4) Following these principles is not only a moral and legal requirement, but also amplifying user base.

What is the H5 tag in HTML?What is the H5 tag in HTML?May 09, 2025 am 12:11 AM

The H5 tag in HTML is a fifth-level title that is used to tag smaller titles or sub-titles. 1) The H5 tag helps refine content hierarchy and improve readability and SEO. 2) Combined with CSS, you can customize the style to enhance the visual effect. 3) Use H5 tags reasonably to avoid abuse and ensure the logical content structure.

H5 Code: A Beginner's Guide to Web StructureH5 Code: A Beginner's Guide to Web StructureMay 08, 2025 am 12:15 AM

The methods of building a website in HTML5 include: 1. Use semantic tags to define the web page structure, such as, , etc.; 2. Embed multimedia content, use and tags; 3. Apply advanced functions such as form verification and local storage. Through these steps, you can create a modern web page with clear structure and rich features.

H5 Code Structure: Organizing Content for ReadabilityH5 Code Structure: Organizing Content for ReadabilityMay 07, 2025 am 12:06 AM

A reasonable H5 code structure allows the page to stand out among a lot of content. 1) Use semantic labels such as, etc. to organize content to make the structure clear. 2) Control the rendering effect of pages on different devices through CSS layout such as Flexbox or Grid. 3) Implement responsive design to ensure that the page adapts to different screen sizes.

H5 vs. Older HTML Versions: A ComparisonH5 vs. Older HTML Versions: A ComparisonMay 06, 2025 am 12:09 AM

The main differences between HTML5 (H5) and older versions of HTML include: 1) H5 introduces semantic tags, 2) supports multimedia content, and 3) provides offline storage functions. H5 enhances the functionality and expressiveness of web pages through new tags and APIs, such as and tags, improving user experience and SEO effects, but need to pay attention to compatibility issues.

H5 vs. HTML5: Clarifying the Terminology and RelationshipH5 vs. HTML5: Clarifying the Terminology and RelationshipMay 05, 2025 am 12:02 AM

The difference between H5 and HTML5 is: 1) HTML5 is a web page standard that defines structure and content; 2) H5 is a mobile web application based on HTML5, suitable for rapid development and marketing.

HTML5 Features: The Core of H5HTML5 Features: The Core of H5May 04, 2025 am 12:05 AM

The core features of HTML5 include semantic tags, multimedia support, form enhancement, offline storage and local storage. 1. Semantic tags such as, improve code readability and SEO effect. 2. Multimedia support simplifies the process of embedding media content through and tags. 3. Form Enhancement introduces new input types and verification properties, simplifying form development. 4. Offline storage and local storage improve web page performance and user experience through ApplicationCache and localStorage.

See all articles

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 Article

Hot Tools

SecLists

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.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

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.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version