search
HTML Inline-BlockSep 04, 2024 pm 04:18 PM
htmlhtml5HTML TutorialHTML PropertiesHTML tags

HTML has another type of element called Inline Block Elements. It is only the space occupied and bounded by each and every tag called by defined elements instead of breaking the HTML contents flow. The block-level elements feature mainly we consider as

tags same thing we have an Inline Elements tag called primarily focuses on the inline-block elements; there is a slight difference between inline and inline-block elements it allows the user to set width, the height of the Html elements also we have customized the top, bottom and display the content will be inline-block and also paddings will be initialized if the requirements needed.

Syntax of HTML Inline-Block

The basic syntax is followed below:

Syntax:


<p><span> ---some html codes ---</span> </p>

The above codes are basic syntax for writing the inline-block elements in html. We have used some sets of pre-defined inline-block elements below.


  • HTML Inline-Block
  • <script></script>

The above tags are pre-defined html inline elements based on the user requirements in the html mainly; we will focus on tag in html inline-block elements. We all know block-level elements always start a new line and take up with full width for given variables, but inline elements do not start a new line. Also, it takes less width when compared to block-level elements, but it has necessary to declare width in the html inline elements. The inline elements will be declared on the inside of the paragraph elements. The element is often used in the container as some text and has no specific required attributes, but the given css style, class, and ids are common when the element is used together with css in some style parts of the text.

How to Create HTML Inline Block?

  • As discussed in earlier articles, we have created the HTML inline-block elements in the block-level elements. The HTML elements only take the user to allot the given necessary spaces and appear next to each other on the same line of the HTML tags. We can’t control the height and width of the HTML elements; it is the properties of the inline elements.
  • The CSS style attributes called display: inline disregards the padding and margin settings when they need; it will allow the padding and margin values in the HTML. It contains only inline elements and makes block elements appear in a single line with the help of settings like display: inlineWe can use CSS styles to set div tags at 50% width if you don’t want to minimize the HTML codes.it is a CSS solution for inline-block elements.
  • Sometimes we can use white space:no-wrap is the parent container; it will allow the
    tag to display in each div inline-block as we expected without chaining the divs together is also referred to as a nested div tag. We have discussed some inline-block elements that will be used for creating layouts with the help of CSS styles.
  • Suppose we use two divs tags in HTML displayed with the inline-block elements settings in CSS styles. We can set the width of each tag as 50%, but the second div tag falls below the first div tag.
  • Code:

    
    section {
    background: green;
    box-sizing: border-box;
    padding: 150px;
    }
    div {
    box-sizing: border-box;
    display: inline-block;
    height: 100px;
    padding: 54px;
    text-align: center;
    width: 53%;
    }
    .green {
    background: lightgreen;
    }
    .black {
    background: black;
    }
    
    
    <span style="border: 2px lightgreen">
    </span>
    <section>
    <div class="green">Width: 40%</div>
    <div class="black">Width: 60%</div>
    </section>
    
    

    Explanation of the above code: In the above codes, we have set the width for two div tags; each will be 50%, and the display attributes will be inline-block. The expected output will vary because the two div tags’ width is 50%, so will change any of the tag values should be 51% or 49%. Still, it is not a good practice and also not enough for the HTML element space; it needs at least 50% because inline elements respect with word spacing between the two div tags in HTML.

    We can also use some borders and padding styles in the HTML div tags; it will highlight the web pages more effectively. We use

    tag called block-level elements for the above codes. We use the tag as the inline element tag; we will use some contents inside the tags that will be required on the web page.

    Examples to Implement in Inline-Block

    We will discuss the below examples.

    Example #1

    Code:

    
    <p>Sample <span style="border:3px green">Welcome</span>To my domain</p>
    <p>Welcome to My Domain</p>
    
    

    Output:

    HTML Inline-Block

    Example #2

    Code:

    
    <style>
    span.first {
    display: inline;
    width: 150px;
    height: 120px;
    padding: 8px;
    border: 3px  blue;
    background-color: green;
    }
    span.second {
    display: inline-block;
    width: 140px;
    height: 110px;
    padding: 7px;
    border: 3px blue;
    background-color: green;
    }
    span.third {
    display: block;
    width: 103px;
    height: 110px;
    padding: 6px;
    border: 2px yellow;
    background-color: black;
    }
    </style>
    
    
    <div> Welcome to My Domain
    <span class="first">Welcome</span>
    <div>
    <div> Same Same
    <span class="second">Same Same</span>
    <div>
    <div> Welcome to My Domain
    <span class="third">Welcome</span>
    <div>
    
    
    <p><strong>Output:</strong></p>
    <p><img  src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/172543794134319.png?x-oss-process=image/resize,p_40" class="lazy" alt="HTML Inline-Block" ></p>
    
    
    <h4 id="Example">Example #3</h4>
    <p><strong>Code:</strong></p>
    <pre class="brush:php;toolbar:false">
    
    <style>
    .first {
    float:center;
    display: inline;
    width: 150px;
    height: 120px;
    padding: 8px;
    border: 3px  blue;
    background-color: green;
    }
    .1{
    clear:center;
    }
    </style>
    
    
    <div class="first"> <marquee> Welcome to My Domain</marquee>
    </div>
    
    

    Output:

    HTML Inline-Block

    Explanation of the above code: The first example will discuss the essential inline element called tag that will use for the web page; the second example will use span in the CSS style, and the same will be called in the tag in body sections each of the CSS styles will be defined in each span third example we will use some text values in the box-limit areas in the inline-block element features.

    Conclusion

    In Conclusion, partly based on the above topics, we have some ideas about inline-block elements in Html. We use both tag elements for their dependencies and features in user areas. However, IE and other browser versions may or may not support some tags.

The above is the detailed content of HTML Inline-Block. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML超文本标记语言--超在那里?(文档分析)HTML超文本标记语言--超在那里?(文档分析)Aug 02, 2022 pm 06:04 PM

本篇文章带大家了解一下HTML(超文本标记语言),介绍一下HTML的本质,HTML文档的结构、HTML文档的基本标签和图像标签、列表、表格标签、媒体元素、表单,希望对大家有所帮助!

html和css算编程语言吗html和css算编程语言吗Sep 21, 2022 pm 04:09 PM

不算。html是一种用来告知浏览器如何组织页面的标记语言,而CSS是一种用来表现HTML或XML等文件样式的样式设计语言;html和css不具备很强的逻辑性和流程控制功能,缺乏灵活性,且html和css不能按照人类的设计对一件工作进行重复的循环,直至得到让人类满意的答案。

web前端笔试题库之HTML篇web前端笔试题库之HTML篇Apr 21, 2022 am 11:56 AM

总结了一些web前端面试(笔试)题分享给大家,本篇文章就先给大家分享HTML部分的笔试题(附答案),大家可以自己做做,看看能答对几个!

HTML5中画布标签是什么HTML5中画布标签是什么May 18, 2022 pm 04:55 PM

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

总结HTML中a标签的使用方法及跳转方式总结HTML中a标签的使用方法及跳转方式Aug 05, 2022 am 09:18 AM

本文给大家总结介绍a标签使用方法和跳转方式,希望对大家有所帮助!

html5废弃了哪个列表标签html5废弃了哪个列表标签Jun 01, 2022 pm 06:32 PM

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

html中document是什么html中document是什么Jun 17, 2022 pm 04:18 PM

在html中,document是文档对象的意思,代表浏览器窗口的文档;document对象是window对象的子对象,所以可通过“window.document”属性对其进行访问,每个载入浏览器的HTML文档都会成为Document对象。

html5支持boolean值属性吗html5支持boolean值属性吗Apr 22, 2022 pm 04:56 PM

html5支持boolean值属性;boolean值属性指是属性值为true或者false的属性,如input元素中的disabled属性,不使用该属性表示值为flase,不禁用元素,使用该属性可以不设置属性值表示值为true,禁用元素。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software