Home > Web Front-end > HTML Tutorial > Detailed explanation of HTML5+CSS3 application

Detailed explanation of HTML5+CSS3 application

不言
Release: 2018-05-08 15:23:56
Original
1843 people have browsed it

This article mainly introduces the detailed explanation of HTML5 CSS3 application, which has certain reference value. Now I share it with you. Friends in need can refer to it.

Now, HTML5 and CSS3 are eagerly waiting for everyone. Let’s see if they can really take our designs to the next level

Web designers can do some cool stuff using HTML4 and CSS2.1. We can complete the logical structure of documents and create content-rich websites without using the old table-based layout. We can add beautiful and subtle styling to our website without using inline and
tags. In fact, our current design capabilities have taken us far away from that terrible era of browser wars, proprietary protocols, and those ugly web pages filled with flashes, scrolls, and flashes.

Although we have now commonly used HTML4 and CSS2.1, we can do better! We can restructure our code and make our page code more semantic. We can reduce the amount of styling code that gives pages a beautiful look and make them more scalable. Now, HTML5 and CSS3 are eagerly waiting for everyone. Let's see if they can really bring our design to the next level...

In the past, designers often used the software based on The table has no semantic layout. But in the end, thanks to innovators like Jeffrey Zeldman and Eric Meyer, smart designers slowly accepted the relatively more semantic

layout instead of the table layout, and began to call external style sheets. But unfortunately, complex web design requires a lot of different tag structure code, we call it "

-soup" syndrome. Maybe you are familiar with the following code:

Copy code

The code is as follows:

 <div class="section"> 
      <div class="article"> 
        <div class="header"> 
            <h1>Div Soup Demonstration</h1> 
            <p>Posted on July 11th, 2009</p> 
        </div> 
        <div class="content"> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
        </div> 
        <div class="footer"> 
            <p>Tags: HMTL, code, demo</p> 
        </div> 
      </div> 
      <div class="aside"> 
        <div class="header"> 
            <h1>Tangential Information</h1> 
        </div> 
        <div class="content"> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
        </div> 
        <div class="footer"> 
            <p>Tags: HMTL, code, demo</p> 
        </div> 
      </div> 
  </div> 
</div>
Copy after login

Although this is a bit reluctant, the above example can still illustrate that using HTML4 to code a complex design is still too bloated (in fact, xHTML1.1 is nothing more than that). But what’s exciting is that HTML5 solves the “

-soup” syndrome and gives us a new set of structural elements. These new HTML5 elements have more detailed semantics to replace those meaningless

tags, and at the same time provide "natural" CSS hooks for CSS calls.

The following is an example of an HTML5 solution:

Copy the code

The code is as follows:

<section> 
      <article> 
        <header> 
            <h1>p Soup Demonstration</h1> 
            <p>Posted on July 11th, 2009</p> 
        </header> 
        <section> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
        </section> 
        <footer> 
            <p>Tags: HMTL, code, demo</p> 
        </footer> 
      </article> 
      <aside> 
        <header> 
            <h1>Tangential Information</h1> 
        </header> 
        <section> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
            <p>Lorem ipsum text blah blah blah.</p> 
        </section> 
        <footer> 
            <p>Tags: HMTL, code, demo</p> 
        </footer> 
      </aside> 
  </section> 
</section>
Copy after login

As we can see, HTML5 allows us to replace a large number of meaningless

tags with many more semantic structured code tags. This semantic feature not only improves the quality and semantics of our web pages, but also greatly reduces the class and id attributes that must be called for CSS in the code. In fact, CSS3 also allows us to ignore all classes and ids.

Say goodbye to class attributes and welcome neat tags 

Combined with HTML5 rich in new semantic tags, CSS3 provides web designers with magic for their web pages. General strength. With the power of HTML5, we will get more control over the document code. With the power of CSS3, our control will become infinite!

Even without those advanced CSS selectors, we can still call different containers through powerful HTML5 clauses without bothering with attributes such as class and id. Like the previous p layout, we may have to call it like this in css: p#news {}

Copy code

The code is as follows:

div.section {} 
div.article {} 
div.header  {} 
div.content {} 
div.footer  {} 
div.aside  {}
Copy after login

Let’s take a look at an example based on HTML5: section {}

Copy code

The code is as follows:

article {} 
header  {} 
footer  {} 
aside  {}
Copy after login

This is progress, but there are still some issues that need to be resolved. In the

example, we need to call the element in the page through the class or id attribute. This logic will allow us to apply styles to any element in the document, whether as a whole or individually. For example, in the

example, the .section and .content elements are easy to locate. But in the HTML5 example, there will be many section elements in the actual document. Actually, we could add some specific attribute selectors to call those different section elements, but thankfully, I don't have a few advanced CSS selectors to target different section elements now.

Locating HTML-5 elements without using class and id

Let’s take a look at how to locate an instance of HTML5 page elements without using class and id. We can use three A CSS selector to locate and identify elements within an instance. as follows:

后代选择器:[CSS 2.1]: EF
兄弟选择器:[CSS 2.1]: E + F
子元素选择器:[CSS 2.1]: E > F

下面让我们来看看如何不使用class和id而完成对文档中的那些section元素的定位吧:

定位最外层的

元素

  考虑到我们的例子并不是一套完整的HTML5代码,所以我们假定在元素下有个

Related labels:
css
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template