Home Web Front-end HTML Tutorial CSS standard: vertical-align attribute_HTML/Xhtml_Web page production

CSS standard: vertical-align attribute_HTML/Xhtml_Web page production

May 16, 2016 pm 04:45 PM
bottom top element Attributes standard Browser


Original text: http://www.mikkolee.com/13
I have carefully studied the vertical-align attribute in the past few days, and the result surprised me. This very "senior" CSS standard actually behaves differently in various browsers.
Vertical-align has many values, including baseline sub supper top text-top bottom text-bottom middle and various length values ​​(%, em, ex, etc.). Let me first show you a value that I think is the most exaggerated: bottom. The code is as follows:
p {
font-size: 18px;
line-height: 36px;
font-family: Tahoma, sans-serif;
}
img {
vertical-align: bottom ;
}

Then let’s take a look at the effect of this CSS in various browsers (I made the picture like that intentionally so that I can see the relative position clearly):





Well, this result is actually very surprising. Generally, I would think that Firefox would explain it more correctly than IE, but after looking at Opera, I found that it is the same as IE, while Safari/Win is on the side of Firefox. To be honest, I don't know what's going on.
I carefully studied the "CSS Definitive Guide (Second Edition)", and even consulted W3C, and then made a diagram about vertical-align myself:

According to the W3C definition, when the vertical-align of an inline element is set to: When baseline, top, and bottom are used, the baseline (or middle, top, bottom) of the element is aligned with the same position of the surrounding elements, such as the top of the picture aligned with the top of the surrounding text. When text-top and text-bottom are used, the top (or bottom) of the element is aligned with the text-top (or text-bottom) of the surrounding elements. The length (%, em, ex) is moved upward based on the baseline, so positive numbers go up and negative numbers go down. When in middle, the center of the element is aligned with the center of surrounding elements. The definition of "center" here is: the picture is of course half the height, and the text should be moved upward 0.5ex based on the baseline, that is, the exact center of the lowercase letter "x". However, many browsers often define the unit of ex as 0.5em, so that it is not necessarily the exact center of x (for example, in the above picture, the height of x should be 10px, and em is 18px, so the two values ​​​​are different).
However, even following the above guidelines, it boggles my mind that each browser’s interpretation is so different. I'm too lazy to research why this is the case. Generally speaking, it should be that they have different definitions of the position of each line of the font, so this problem is not only related to vertical-align, but to the browser's interpretation of the structure of inline text and inline images. It has a lot to do with it.
Finally, I will give you a test page to see how each browser interprets different values ​​of vertical-align.
http://www.mikkolee.com/weblab/001_vertical/
You can test other values, such as middle or text-top, as each browser is completely different. Let’s discuss what you think~~
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Coinbase Exchange Login Port 2025 Coinbase Exchange Login Port 2025 Mar 21, 2025 pm 05:51 PM

Coinbase Security Login Guide: How to Avoid Phishing Sites and Scams? Phishing and scams are becoming increasingly rampant, and it is crucial to securely access the Coinbase official login portal. This article provides practical guides to help users securely find and use the latest official login portal of Coinbase to protect the security of digital assets. We will cover how to identify phishing sites, and how to log in securely through official websites, mobile apps or trusted third-party platforms, and provide suggestions for enhancing account security, such as using a strong password and enabling two-factor verification. To avoid asset losses due to incorrect login, be sure to read this article carefully!

The latest registration portal for Ouyi official website The latest registration portal for Ouyi official website Mar 21, 2025 pm 05:54 PM

As the world's leading digital asset trading platform, Ouyi OKX attracts many investors with its rich trading products, strong security guarantees and convenient user experience. However, the risks of network security are becoming increasingly severe, and how to safely register the official Ouyi OKX account is crucial. This article will provide the latest registration portal for Ouyi OKX official website, and explain in detail the steps and precautions for safe registration, including how to identify the official website, set a strong password, enable two-factor verification, etc., to help you start your digital asset investment journey safely and conveniently. Please note that there are risks in digital asset investment, please make cautious decisions.

Ouyi Exchange app domestic download tutorial Ouyi Exchange app domestic download tutorial Mar 21, 2025 pm 05:42 PM

This article provides a detailed guide to safe download of Ouyi OKX App in China. Due to restrictions on domestic app stores, users are advised to download the App through the official website of Ouyi OKX, or use the QR code provided by the official website to scan and download. During the download process, be sure to verify the official website address, check the application permissions, perform a security scan after installation, and enable two-factor verification. During use, please abide by local laws and regulations, use a safe network environment, protect account security, be vigilant against fraud, and invest rationally. This article is for reference only and does not constitute investment advice. Digital asset transactions are at your own risk.

Binance Exchange app domestic download tutorial Binance Exchange app domestic download tutorial Mar 21, 2025 pm 05:45 PM

This article provides a safe and reliable Binance Exchange App download guide to help users solve the problem of downloading Binance App in the country. Due to restrictions on domestic application stores, the article recommends priority to downloading APK installation packages from Binance official website, and introduces three methods: official website download, third-party application store download, and friends sharing. At the same time, it emphasizes security precautions during the download process, such as verifying the official website address, checking application permissions, scanning with security software, etc. In addition, the article also reminds users to understand local laws and regulations, pay attention to network security, protect personal information, beware of fraud, rational investment, and secure transactions. At the end of the article, the article once again emphasized that downloading and using Binance App must comply with local laws and regulations, and at your own risk, and does not constitute any investment advice.

Log in to the latest official website of BitMEX exchange Log in to the latest official website of BitMEX exchange Mar 21, 2025 pm 06:06 PM

This article provides safe and reliable guides to help users access the latest official website of BitMEX exchange and improve transaction security. Due to regulatory and cybersecurity threats, it is crucial to identify the official BitMEX website and avoid phishing websites stealing account information and funds. The article introduces the search for official website portals through trusted cryptocurrency platforms, official social media, news media, and subscribes to official emails. It emphasizes the importance of checking domain names, using HTTPS connections, checking security certificates, and enabling two-factor verification and changing passwords regularly. Remember, cryptocurrency trading is high risk, please invest with caution.

Coinbase Exchange web version login portal Coinbase Exchange web version login portal Mar 21, 2025 pm 05:48 PM

The Coinbase exchange web version is popular for its convenience, but secure access is crucial. This article aims to guide users to log in to the official Coinbase web version safely and avoid phishing websites and hackers. We will explain in detail how to verify the official portal through search engines, trusted third-party platforms and official social media, and emphasize security measures such as checking the address bar security lock, enabling two-factor verification, avoiding public Wi-Fi, changing passwords regularly, and being alert to phishing emails to ensure the security of your digital assets. Correct access to the official Coinbase website is the first step to protecting your digital currency. This article will help you start your digital currency trading journey safely.

BitMEX Exchange's latest official website entrance BitMEX Exchange's latest official website entrance Mar 21, 2025 pm 06:03 PM

As a veteran cryptocurrency derivatives trading platform, the accuracy of its official website entrance is crucial. Due to rampant phishing websites, misent entry into fake websites can lead to account theft and loss of funds. This article aims to guide users to safely access the BitMEX official website, provide various methods such as trusted cryptocurrency information platforms (such as CoinMarketCap, CoinGecko), official social media, verification of existing addresses and official support channels, and emphasizes the use of security measures such as two-factor verification, regular password changes and use of security software to help users effectively avoid risks and ensure account security.

How to download Binance in the country How to download Binance in the country Mar 21, 2025 pm 05:33 PM

This article provides a guide to safely downloading the Binance App in China. Due to restrictions on domestic app stores, it is difficult to download directly. It is recommended to download the APK installation package through the Binance official website or scan the QR code to download the App. Be sure to carefully check the official domain name, check the application permissions, perform a secure scan after installation, and enable two-factor verification (2FA). Please be sure to understand and abide by local laws and regulations before downloading and using it. The risk of digital asset transactions is high, so please operate with caution. This article is for reference only and does not constitute investment advice. All risks are borne by the user. Keywords: Binance, Binance, Download, App, Domestic, Security, Tutorial, Digital Currency, Cryptocurrency

See all articles