IMG tag basic analysis In HTML5, the img tag has four elements: (1) src: image path (2) width: The role of alert: When an error occurs in an image, use the function in alt to indicate the error content for easy search engine crawling (convenient for search engine crawling and SEO rendering) Note: (1) The width and height set for img must be the original size of the image. (2) Generally, inline elements cannot set width and height. Although img is also an inline element, it is a replaced element and can be set through src. The difference between inline elements and inline elements. How to solve the spacing problem between inline elements: The reasons for the upper and lower gaps in the inline elements in the figure below are: img is an inline element => inline elements will generate line breaks in the element code by default (also called whitespace => can also be used as a text string by default) The reason for the vertical gap between inline elements in the following figure: The default baseline alignment of inline elements causes empty nodes to appear (vertical-align: baseline;) Solution 1: Because inline elements are treated as strings, you can add a font-size: 0 to the parent; the alignment becomes: vertical-align: middle; but this may cause problems with the text style in the parent Solution 2: Use display to change from an inline element to a block-level element: Note: vertical-align and line-height are the two most difficult knowledge points to understand in CSS: Why can font-size = 0 be changed? Can the blank node of img be made to disappear? Text and image example: Use span tags with images The alignment of the two inline elements is vertical-align: baseline; it is obvious that the text exceeds the baseline of the image. In the following figure, the text size is changed, and the vertical gap between the images also increases. Causes: The text will have a default line height, which causes vertical spacing between the text. The larger the text, the larger the spacing. => When "vertical-align: miiddle;" is used, the text position will rise and no spacing will be generated as shown below The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: iframe src assignment problem (server side)
>>: Vue implements the sample code of associating the side navigation bar with the Tab page
Table of contents Preface environment Install Cre...
External temporary tables A temporary table creat...
Table of contents Before MySQL 5.6 After MySQL 5....
1. This is a bit complicated to understand, I hop...
When playing music, the lyrics will gradually fil...
1. Introduction Supervisor is a general process m...
There are many loopholes in the simple seamless s...
background Today, while cooperating with other pr...
1. Installation of the decompressed version (1). ...
This article example shares the specific code of ...
CSS attribute selectors are amazing. They can hel...
Preface: Because many business tables use design ...
1. Unzip the downloaded MySQL compressed package ...
1. Brigde——Bridge: VMnet0 is used by default 1. P...
When doing web development, you may encounter the...