Home Web Front-end CSS Tutorial How to optimize HTML web pages

How to optimize HTML web pages

Nov 29, 2017 am 10:26 AM
html optimization Web page

We know that in HTML, you not only have to make good-looking web pages, but also consider the optimization of web pages. So today I will give you ideas on how to optimize HTML web pages. I have summarized 5 points. Let’s take a look

Change table to div layout

Try to reconstruct the table tag layout html into the div layout, which can save at least 40% of the code. Since the div code is less than the html webpage with table layout, the search engine index weight is also better than the html webpage with table layout. Reduce and streamline div, span, ul li and other series of tags

When laying out DIV+CSS web pages, we can sometimes save some DIV layout code and reduce the amount of code.

The following case code:

<div class="div"> 
  <ul> 
  <li>DIV</li> 
  <li>DIV</li> 
  <li>DIV</li> 
  </ul> 
</div>
Copy after login

can be changed to:

    lass="div"> 
      <li>DIV</li> 
      <li>DIV</li> 
      <li>DIV</li> 
    </ul>
    Copy after login

    This can save a pair of div tags, thereby reducing the amount of html code , which plays the role of compressing html. In this way, directly naming the css style class for ul can distinguish the use of ul li list tags in different places on a page.

    Delete

    Excess spaces Delete excess spaces and line breaks, which can effectively compress the bytes occupied by the html code. Generally, after the development is completed, the code in the html can be deleted, line breaks, and line breaks. Space content.

    You can use DW software to batch delete spaces between tags in html

    For example:

    <div class="div"> 
      <div ...></div> 
    </div>
    Copy after login

    You can delete spaces and line breaks:

    < div class="div">

This can save bytes occupied by spaces and line breaks.

Note that the published version of the web page can use DW to delete redundant spaces and blank lines. If you want to edit again, go to DW software to format the code.

Table

In type layout, use table instead of div layout appropriatelyIf it is a table data list layout, we'd better choose table, because using table for table layout is better than div layout, using table layout saves

html tag

code and saves css style than div layout. As shown in the table below

Data type

, it is recommended to use TABLE tag + CSS style layouthtml web page code compression table tag layout table

Similar to this list Table table, it is recommended to use the table tag layout

Webpage GZIP Compression

It is recommended to set the webpage Gzip compression function on your own server.

1. What are the benefits of opening GZIP?

Answer: After Gzip is turned on, the data output to the user's browser will be compressed, which will reduce the amount of data transmitted through the network and increase the browsing speed.

2. How to enable the Gzip compression function of IIS:

Answer: First, if you need to compress static files (HTML), you need to create a directory on the hard disk and give it "IUSR_ Write permissions for the user "Machine Name". If you compress dynamic files (PHP, asp, aspx), there is no need, because its pages are dynamically generated every time and will be given up after compression. Then in the IIS manager, right-click on "Website" - Properties, not a certain site below, but the entire website. Enter the "Services" tab and select Enable dynamic content compression and static content compression. Then select the server extension under the website and create a new server extension. The name doesn't matter, the path to add the file below is: c:\windows\system32\inetsrv\gzip.dll, and then enable this extension. At this time, static content can be compressed, but for dynamic content, aspx files are not within the compression range. Because the default compressible file does not have this extension. And you can't find a place to add an extension in the management interface. At this time, you can only modify its

config file

. There is a MetaBase.xml file under c:\windows\system32\inetsrv\. You can open it with Notepad and find IIsCompressionScheme. There are three sections with the same name, namely deflate, gzip, and Parameters. Don’t worry about the third section. The two paragraphs have basically the same parameters. Add a line of aspx below the parameter HcScriptFileExtensions in these two paragraphs. If you have other dynamic programs to compress, add them here. HcDynamicCompressionLevel is changed to 9, (0-10, 9 is the most cost-effective one). Then you need to restart the IIS service to experience the speed after compression. I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!


Related reading:

Implementation steps of Js operating window object


Js operates non-IE event object properties, detailed introduction of the method


Use DIV and CSS to make a red box with a solid border

The above is the detailed content of How to optimize HTML web pages. 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)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles