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

WeChat applet uniapp realizes the left swipe to delete effect (complete code)

WeChat applet uniapp realizes the left swipe to d...

MySQL 8.0 upgrade experience

Table of contents Preface 1. First completely uni...

Detailed explanation of Vue's seven value transfer methods

1. From father to son Define the props field in t...

Vue realizes price calendar effect

This article example shares the specific code of ...

Summary of H5 wake-up APP implementation methods and points for attention

Table of contents Preface Jump to APP method URL ...

CSS scroll bar style modification code

CSS scroll bar style modification code .scroll::-...

Question about custom attributes of html tags

In previous development, we used the default attr...

MySQL 5.7 Common Data Types

——Notes from "MySQL in Simple Terms (Second ...

Command to view binlog file creation time in Linux

Table of contents background analyze method backg...

JavaScript macrotasks and microtasks

Macrotasks and Microtasks JavaScript is a single-...

Using MySQL in Windows: Implementing Automatic Scheduled Backups

1. Write a backup script rem auther:www.yumi-info...

CSS3 realizes the animation effect of lotus blooming

Let’s look at the effect first: This effect looks...