Summary of considerations for writing web front-end code

Summary of considerations for writing web front-end code
1. It is best to add a sentence like this before the html tag

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >

The code indicates that a certain set of W3C standards are followed. The specific set of standards used varies from person to person.

The advantage of using this standard is that you no longer have to worry about different website layouts in different browser environments. After using this standard, the author tested it in IE8, FF, and Safari browser environments, and the result page display was normal. In addition, it was found that after using this standard, some bugs in IE itself no longer appeared. For example, the bug that the height of the div box in IE defaults to be greater than the font height no longer appeared after following this standard.

One thing to note when following this standard is that some non-standard code may not work properly. For example, in JavaScript there is the code roll1right.innerHTML = roll1left.innerHTML;, where roll1right and roll1left are the IDs of two different divs on the web page. The web page can work without applying the standard, but this statement will have a bug under the W3C standard. The reason is that W3C requires that all variables have clear assignments, so you must add the statement var roll1right = document.getElementById("roll1right"); before this statement, and then the code will work properly.

2. When using div and table in a web page, I found that: although the border, margin, and padding of div and table can be set to 0 through CSS, the table will still have a certain amount of space while the div displays normally. After searching W3CSchool, I found that table has two attributes: cellpadding and cellspacing. The cellpadding attribute specifies the space between the cell edge and the content, while the cellspacing attribute specifies the space between cells. So I set the cellpadding and cellspacing properties of the table on the web page to 0. Sure enough, there was no gap between the tables on the web page, and the problem was solved.

<<:  Vue implements mobile phone verification code login

>>:  The difference between div and span in HTML (commonalities and differences)

Recommend

How to distinguish MySQL's innodb_flush_log_at_trx_commit and sync_binlog

The two parameters innodb_flush_log_at_trx_commit...

The whole process of implementing the summary pop-up window with Vue+Element UI

Scenario: An inspection document has n inspection...

HTML basic summary recommendation (text format)

HTML text formatting tags 標簽 描述 <b> 定義粗體文本 ...

CentOS method to modify the default ssh port number example

The default ssh port number of Linux servers is g...

What are the differences between xHTML and HTML tags?

All tags must be lowercase In XHTML, all tags must...

Graphical steps of zabbix monitoring vmware exsi host

1. Enter the virtualization vcenter, log in with ...

Tomcat server security settings method

Tomcat is an HTTP server that is the official ref...

Example of how to create a local user in mysql and grant database permissions

Preface When you install MySQL, you usually creat...

Vue implements 3 ways to switch tabs and switch to maintain data status

3 ways to implement tab switching in Vue 1. v-sho...

Summary of how to use the MySQL authorization command grant

How to use the MySQL authorization command grant:...

Differences in the hr separator between browsers

When making a web page, you sometimes use a dividi...

Solution to SNMP4J server connection timeout problem

Our network management center serves as the manag...

HTML form tag tutorial (1):

Forms are a major external form for implementing ...

MySQL 5.7.20 installation and configuration method graphic tutorial (win10)

This article shares the installation and configur...