Publish a hack md article explaining the difference between inline, block and inline block elements
INTRODUCTION
When working with HTML and CSS, one of the foundational concepts you’ll encounter is how elements are displayed on a web page. This is determined by their display property, which dictates how elements are rendered in the flow of the document. The three primary types of display properties are inline, block, and inline-block. Each has distinct characteristics and use cases, which we'll explore in this article.
BLOCK LEVEL ELEMENTS
In HTML, block-level elements are used to define the structure of web pages. They are called "block-level" because they create a block that takes up the full width available to them on the web page. Some of the most common block-level elements include:
div: The div element is a generic container that is used to group elements together and apply styles to them.
p: The p element is used to define a paragraph of text.
h1, h2, h3, h4, h5, h6 : The heading elements are used to define different levels of headings.
ul: The unordered list element is used to define a bulleted list.
ol: The ordered list element is used to define a numbered list.
li: The list item element is used to define an item in a list.
table: The table element is used to define a table.
form: The form element is used to define a form for user input.
hr: The horizontal rule element is used to create a horizontal line.
header, footer, section, article, aside: The semantic elements are used to give meaning to the content on a web page, and to help search engines and other technologies better understand the content.
Block-level elements are typically used for larger pieces of content that need to be organized on a page, while inline-level elements are used for smaller pieces of content that are part of a larger block.
INLINE ELEMENTS
Inline elements: Inline elements occupy only enough width that is sufficient to it and allows other elements next to it which are inline. Inline elements don’t start from a new line and don’t have top and bottom margins as block elements have.
Examples of Inline elements:
<a>: This tag is used for including hyperlinks in the webpage.
<br>: This tag is used for mentioning line breaks in the webpage wherever needed.
<script>: This tag is used for including external and internal JavaScript codes.
<input>: This tag is used for taking input from the users and is mainly used in forms.
<img>: This tag is used for including different images in the webpage to add beauty to the webpage.
<span>: This is an inline container that takes necessary space only.
<b>: This tag is used in places where bold text is needed.
INLINE-BLOCK LEVEL ELEMENTS
In HTML and CSS, an inline-block element is a hybrid of block-level and inline-level elements. It behaves like an inline-level element in that it flows with surrounding text, but it also behaves like a block-level element in that it can have padding, margins, and a specified width and height.
Some of the most common inline-block elements include:
button: The button element is used to define a clickable button on a web page.
input: The input element is used to create input fields for users to enter data, such as text, numbers, or dates.
select: The select element is used to create a drop-down list of options for users to choose from.
textarea: The textarea element is used to create a larger text input field for users to enter longer passages of text.
label: The label element is used to define a label for an input field or other form element.
img: The image element can be used as an inline-block element when it is given a specified width and height.
Inline-block elements are useful for creating components that need to be aligned horizontally with other inline-level elements, but also need to have a specific width, height, or padding. They can be styled using CSS, just like other HTML elements, to achieve a wide range of visual effects.
Conclusion
By leveraging these different display properties, you can create flexible, responsive layouts that enhance the user experience on your website.