HTML+CSS Easy to Get Started with Inline Block Elements
Inline-block elements have the characteristics of both inline elements and block elements
So how to set elements as inline block elements
display:inline-block;
Note: (new in css2.1), <img>, <input> tags are such inline block tags.
Characteristics of inline block elements
1, and other elements are on the same line;
2 , the element's height, width, line height, and top and bottom margins can all be set.
Let’s write an example below to set the width, height, background color, etc. for an a tag. The a tag is an inline element by default, and the width and height have no effect.
The code is as follows:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
a{
display:inline-block; /*内联块状元素*/
width:300px;
height:200px;
background-color:green;
color:red;
}
</style>
</head>
<body>
<a href="#">欢迎大家来到php中文网</a>
</body>
</html>As shown in the above code, when we convert the a tag into an inline block element, we can set the width and height
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~ 















