<spacer>

HTML <spacer> Tag

The <spacer> element is used to insert spaces on the web page.

Sometimes you may need to put space into your document. Often this is done with the use of invisible images that can be fully transparent, or have the same color as the background. However, these methods aren’t reliable. To include blank space in a document, you can use the <spacer> element. It is like an image, but actually, there isn’t a picture there.

You should specify <spacer> as one of the following types: horizontal, vertical, and block, which can be both horizontal and vertical. To do this, use the type attribute.

Modern browsers don’t support the <spacer> tag. Use HTML <pre> and <br> tags, or CSS margin and padding properties instead.

There are many options for adding and controlling blank space on the web-page:

  • The <p> tag creates a paragraph break.

  • The <br> tag indicates a line break.

  • The <pre> tag is used with a preformatted text. It instructs the browser that the text should appear exactly as it is in the HTML file, including blank lines and spaces.

  • The   character creates non-breaking space.

  • The and characters create tab spaces in HTML. But they can’t be used independently.

  • You can also add space around a text with CSS. (-您还可以使用CSS在文本周围添加空格。)

Syntax

Syntax (语法)

The <spacer> tag is empty, which means that the closing tag isn’t required.

Example of the HTML <spacer> tag:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document </title>
   <style>
     div {
       display: block;
       text-align: center;
     }
   </style>
 </head>
 <body>
   <div>
     PageUp↑
(上一页)
     <br> ←Home
     <spacer type="horizontal" width="100" height="100"> ♢ </spacer>
     End→
(结束)
     <br> PageDown↓
   </div>
 </body>
</html>

Result

Attributes

Attributes (属性)

AttributeValueDescription
alignalignDefines the alignment of the element relative to the content.
heightheightDefines the height of empty space in pixels.
sizesizeDefines the pixel number of empty space, depending on the type attribute.
typeblockhorizontalverticalIndicates the element type.
widthwidthDefines the width of an empty space in pixels.

The <spacer> tag supports the Global Attributes and the Event Attributes.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部