惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
美团技术团队
博客园 - 聂微东
博客园 - 叶小钗
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园_首页
Spread Privacy
Spread Privacy
J
Java Code Geeks
雷峰网
雷峰网
宝玉的分享
宝玉的分享
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Privacy International News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
量子位
L
LINUX DO - 热门话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
GRAHAM CLULEY
D
Darknet – Hacking Tools, Hacker News & Cyber Security
月光博客
月光博客
腾讯CDC
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tor Project blog
罗磊的独立博客
V
Vulnerabilities – Threatpost
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
Project Zero
Project Zero
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
MyScale Blog
MyScale Blog
T
The Exploit Database - CXSecurity.com
GbyAI
GbyAI
博客园 - 【当耐特】
O
OpenAI News
Schneier on Security
Schneier on Security
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Securelist
博客园 - 司徒正美

Henri Sivonen’s pages

Parin vuoden tutkimattomuus crates.io: Rust Package Registry Asiakirjatonta toimintaa It’s not wrong that "🤦🏼‍♂️".length == 7 Koulutartuntojen tilastointimenettely Perusteasiakirjoja hallussapitämättä ikärajoitettu Asiantuntijat ja nukkuva vallan vahtikoira Koronapassilausunto Suppealla tietopohjalla ohimeneväksi väitetty Text Encoding Menu in 2021 The Text Encoding Submenu Is Gone An HTML5 Conformance Checker Not Part of the Technology Stack Browser Technology Stack Bogo-XML Declaration Returns to Gecko A Look at Encoding Detection and Encoding Menu Telemetry from Firefox 86 Why Supporting Unlabeled UTF-8 in HTML on the Web Would Be Problematic Rust Target Names Aren’t Passed to LLVM Toimintamalli Activating Browser Modes with Doctype Johtopäätöksiä mallin rakenteesta Tehtävänmäärittelyä kirjoittamatta ja kuolemia laskematta laumasuojamallinnettu Character Encoding Menu in 2014 Erillissuosituksen tarpeettomuudesta yleissuosituksen poikkeukseksi? STM:n maskiaikajana Rust 2021 Oma-aloitteisesti mallinnettu Kokopinovaatimuksin kilpailutettu chardetng: A More Compact Character Encoding Detector for the Legacy Web Varauksia paisutellen tiedotettu Perusteasiakirjoitta tiedotettu Always Use UTF-8 & Always Label Your HTML Saying So IME Smoke Testing The Validator.nu HTML Parser About the Hiragino Fonts with CSS It’s Time to Stop Adding New Features for Non-Unicode Execution Encodings in C++ Rust 2020 The Last of the Parsing Quirks About about:blank Rust 2019 a Web-Compatible Character Encoding Library in Rust How I Wrote a Modern C++ Library in Rust Using cargo-fuzz to Transfer Code Review of Simple Safe Code to Complex Code that Uses unsafe A Rust Crate that Also Quacks Like a Modern C++ Library #Rust2018 No Namespaces in JSON, Please A Lecture about HTML5 Julkisesti luotettu varmenne ikidomainille TLS:ää (SSL:ää) varten -webkit-HTML5 Lists in Attribute Values The Sad Story of PNG Gamma “Correction” If You Want Software Freedom on Phones, You Should Work on Firefox OS, Custom Hardware and Web App Self-Hostablility HTML5 Parser Improvements ARIA in HTML5 Integration: Document Conformance (Draft, Take Two) Schema.org and Pre-Existing Communities Lowering memory requirements by replacing Schematron HTML5 Parsing in Gecko: A Build Introducing SAX Tree NVDL Support in Validator.nu HOWTO Avoid Being Called a Bozo When Producing XML An Unofficial Q&A about the Discontinuation of the XHTML2 WG Thoughts on HTML5 Becoming a W3C Recommendation Four Finnish Banks Training Users to Give Banking Credentials to Another Site Unimpressed by Leopard Sergeant Semantics The Content Sink Inheritance Diagram – 2006-06-30 What is EME? About Points and Pixels as Units The Performance Cost of the HTML Tree Builder Social Media Impression Management The spacer Element Is Gone Openmind 2006 Performance Mistake XHTML and Mobile Devices WebM-Enabled Browser Usage Share Exceeds H.264-Enabled Browser Usage Share on Desktop (in StatCounter Numbers) HTML5 Parser-Based View Source Syntax Highlighting Vendor Prefixes Are Hurting the Web Accept-Charset Is No More Dualroids Writing Structural Stylable Document in Mozilla Editor ISO-8859-15 on haitallinen Hourglass The Scientific Method According to Hixie Maemo Source Code Karpelan lukkovertaus ontuu Digitaalisesta arkistoinnista ARIA in HTML5 Integration: Document Conformance (Draft) XHTML—What’s the Point? (Draft, incomplete) Mac OS X Browser Comparison HOWTO Spot a Wannabe Web Standards Advocate An Idea About Intermediate Language Trees and Web UI Generation Thoughts on Using SSL/TLS Certificates as the Solution to Phishing Bureaucracy Meets the Web Europe Day HOWTO Establish a 100% Literacy Rate What to Do with All These Photos? Charmod Norm Checking Validator Web Service Interface Ideas DTDs Don’t Work on the Web EFFI’s Day in Court
Things to Take into Account When Moving to Standards-Compliant HTML and CSS Authoring
Henri Sivonen · 2011-12-22 · via Henri Sivonen’s pages

This document has not been updated in over a decade and is severely out of date. I have kept it available for historical interest only.

This is a mixed collection of different issues that are worth taking into account when writing Web pages according to the W3C Recommendations. I have either run accross the issues myself or seen others run into them when reporting bugs in the Mozilla browser. These issues are faced when people try to apply experience they have from working with quirky browsers to standards-compliant authoring.

Doctype

Pages that comply with the HTML Recommendation must begin with a proper doctype declaration. (However, a doctype declaration should not be included in documents that are not really HTML and CSS compliant!) In order to deal with both old pages written to old browser quirks and with new standards-compliant pages, it important to make sure that the browser is in the mode that suits the content. Both Mozilla and IE 5 for Mac choose the mode based on the doctype declaration of the document.

HTML Containment Rule Issues

Inline Elements in <body>

When using the HTML 4.01 Strict DTD (nesting rules), there can only be block-level elements directly inside <body>—unlike when using the Transitional DTD (nesting rules).

Block-Level Elements in <p>

The <p> element can’t contain any block-level elements including <p> itself. The block-level elements are <p>, headings, lists, <div>, <noscript>, <blockquote>, <form>, <hr>, <pre>, <table>, <fieldset> and <address>.

CSS Inline Box Model Issues

When it comes to images or lines with no text, the CSS line box model is very different from the model used in browsers that imitate the behavior of Netscape Navigator 1.x. The line box model is also the single most difficult thing to grasp about CSS. If line heights on a page “break” in Mozilla’s standard layout mode and “work” in the quirks mode, the page most likely is written to the Navigator 1.x model and not to the CSS line box model. One might argue that the authors of the CSS2 specification should have paid more attention to compatibility with existing browsers when choosing the default values for CSS properties.

The inline box model is discussed in detail in David’s Inline Box Model and Eric Meyer’s Inline formatting model.

Alignment of Images in Inline Elements

[CSS defult behavior] When writing code to the Navigator 1.x model, Web authors have come to expect that code like <a href="..."><img src="..."></a> causes the box of the <a> element stretch to match exactly the box of the <img> element. Not so with CSS!

If the <a> element is given a background color, the colored box of the <a> element extends below the bottom edge of the image.

[Behavior with vertical-align: bottom;] This happens, because the initial value the vertical-align property is baseline. As a result, the bottom edge of the <img> is aligned with <a>’s baseline. In order to align the bottom of the image with the bottom of the box of the <a> element, the vertical-align property of the <img> element could to be set to bottom. Unfortunately, this may cause problems in Opera. The alignment problem usually arises when using tables a layout devices. More on that specific situation below.

Height of Inline Elements Containing Images

The image of the previous example is partially transparent. One can notice that the box of the <a> element doesn’t stretch to the height of the image. This is not a browser bug.

While the height of block-level elements depends (by default) on the contents of the element, the height of inline non-replaced elements (including <a>) depends on the line-height property. As a result, the height of the box of the <a> element does not depend on the height of the image. Tall images just overflow without affecting the height of the line box.

[Behavior with vertical-align: bottom; and background-color: inherit;] The box of the <img> can be made the same color as the box of the <a> by setting the background-color of the <img> to inherit. However, this solution makes no guarantee about the relationship of the line height and the image height.

Image Alignment in Table Cells

The two above-mentioned problems are usually faced when sliced images are placed in a layout table. Using tables with sliced images as a layout device is considered depracated and using floaters and non-sliced images works better with CSS.

If one still wants to use the old table-based layout style, there is an easy combined solution. Setting the display property of the images and the enclosing <a> element to block solves the problem.

That is, if your table cells containing only an image are flagged with class="imgcell", the minimum you need is this style rule in the style sheet:

.imgcell img, .imgcell a { display: block; }

Alternatively, you may wish to make sure that margins, padding and borders defined elsewhere don’t interfere with the images:

.imgcell img, .imgcell a {
    display: block;
    margin: 0;
    border: 0;
    padding: 0;
}

Other CSS Issues

Class and ID Selectors are Case-Sensitive

Even though some browsers treat class and ID selector case-insensitively, class names and IDs are supposed to case-sensitive and will be treated as such by stricter browsers.

In the HTML 4.01 specification both the class attribute and the id attribute are defined to take a value that is case-sensitives.

width is the content width

Despite buggy implementations in some browsers, according to the specification width sets the width of the content area of a box exclusive of padding. If a background color is applied to the box, the width of the colored rectangle is padding-left + width + padding-right.

User Agent Style Sheets Differ

Conforming CSS user agents are required to apply a default style sheet (or behave as if they did) prior to all other style sheets for a document. The default style sheet should present the elements of the document language in ways that satisfy general presentation expectations for the document language.

The CSS2 specification contains a sample style sheet for HTML 4.0. However, the it is informative—not normative. Different browsers have different default style sheets for HTML. Even if a style sheet looks fine in one browser, another browser might have a default style sheet that interacts with the style sheet in an unwanted manner.

For example, some browsers implement the default list indentation using margin-left while others use padding-left. When altering the indentation, it is important to override both properties.

One way to avoid unwanted effects caused by unanticipated style rules in the UA style sheet is to reset padding, margins and borders on all elements to zero. Those properties can then be overridden on selected elements. One could use this rule: * { margin: 0; padding: 0; border: 0; }. However, the universal selector is unsafe on pages with form widgets. Some browsers allow style to be applied to form widgets while other browsers don’t. In order to avoid problems with form widgets, the selector would have to list the names of the other elements.

XHTML Issues

The Correct Namespace URI

Unfortunately the W3C didn’t decide on the XHTML namespace URI right away when it became obvious that such a URI is needed. Different URIs have been used as placeholders in Microsoft’s documentation, in mozilla.org’s old documentation and even in the Namespaces in XML Recommendation! The correct final XHTML namespace URI is “http://www.w3.org/1999/xhtml” (as specified in the XHTML 1.0 Recommendation).

The attribute xmlns:html="http://www.w3.org/1999/xhtml" associates the prefix html with the XHTML namespace. IE 5 (incorrectly) requires the use of the html prefix.