span is not a block element, but an inline element (inline element), which can combine inline elements in the document. span only defines the content as a whole for operation, without affecting the layout and display, and span has no practical features. Its function is to surround other elements in the HTML code and specify styles for them.
(Recommended tutorial: html tutorial)
span is not a block element, but an inline element (inline element ), mainly used to accommodate text. span is used to combine inline elements in the document.
Span only defines the content as a whole for operation, without affecting the layout and display, and span has no practical features. Its function is to surround other elements in the HTML code and specify styles for them.
Tags have no fixed format. It only changes visually when you apply a style to it. If you don't apply styles to , the text in the element will not be visually different from other text.
Tags provide a way to isolate a portion of text or a portion of a document.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <p>我的母亲有 <span style="color:blue;font-weight:bold">蓝色</span> 的眼睛,我的父亲有 <span style="color:darkolivegreen;font-weight:bold">碧绿色</span> 的眼睛。</p> </body> </html>
Rendering:
##Block elements, inline elements, inline elements Block elements:
elements are labels. There are three commonly used labels in layout, block elements, inline elements, and inline block elements. Only by understanding the characteristics of these three elements can you master the page. layout. 1. Block element: Block element can also be called row element. Commonly used tags in layout, such as: div, p, ul, li, h1-h6, etc. are all Block element, its behavior in layout: (1) Supports all styles (2) If the width is not set, the default width is 100% of the parent width(3) The box occupies one line, even if the width is setCode:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>块元素</title> <style type="text/css"> .box{ background-color: gold; /*width:300px;*/ /*height:200px;*/ } .box2{ background-color: green; /*width:300px;*/ /*height:200px;*/ } </style> </head> <body> <div>div元素</div> <p>p元素</p </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>内联元素</title> <style type="text/css"> .box{ width:500px; height:400px; border:1px solid #000; margin:50px auto 0; font-size:0; /* 解决内联元素间隙 */ } .box div{ width:100px; height:100px; margin:10px; background-color:gold; } .box a{ background-color:gold; /* width:300px; height:200px; 设置宽高完全不起作用 */ /* margin:100px 20px; 没有上下的边距,只有左右的边距 */ /*padding:10px 10px;*/ /* padding的上下不应该起作用的,却出现了bug */ font-size:16px;/* 解决内联元素间距 */ } .box2{ width:500px; height:100px; border:1px solid #000; margin:50px auto 0; text-align:center; } </style> </head> <body> <div> <div></div> <div></div> <a href="#">链接文字一</a><a href="#">链接文字二</a> /* 取消间隙 */ <a href="#">链接文字三</a> <a href="#">链接文字四</a> <a href="#">链接文字五</a> </div> <div> <a href="#">链接文字</a> </div> </body> </html>
Programming Learning Website! !
The above is the detailed content of Is span a block element?. For more information, please follow other related articles on the PHP Chinese website!