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
The installation of mysql-5.7.17 is introduced be...
The multi-site feature of WordPress allows you to...
Table of contents Overview Is the extension neces...
Table of contents js deep copy Data storage metho...
Table of contents Preface 1. Basic knowledge of f...
This article records the installation graphic tut...
Since PHP7 came out, as a fan of the latest versi...
I recently added a very simple color scheme (them...
Table of contents Require Implementation Code dat...
Table of contents 1. Cause 2. Equipment Informati...
Table of contents 1. Technical Overview 2. Techni...
1. Problem reproduction: Count the total number o...
In the past few days, the website has been access...
Table of contents 1. Constructors and prototypes ...
This article shows you how to use CSS to create a...