Inline Elements And Block Elements In HTML - Explained
Có thể bạn quan tâm
Block and Inline Elements
Let's understand block and inline elements using the below examples:
Code Sample with Output:
Block-Level Element:
A Block-level element occupies the entire space of the parent (container) such as <div> and <p> in the example .
Note that both <div> and <p> start from a new line each time, forming a block-like structure. Block-level elements begin on new lines.
Common block-level elements are <div>,<p>,<article>,<section>,<figure>,<footer> etc.
Inline Element:
Inline as the name says “included as a part of the main text and not as a separate section”. Inline elements occupy the space as needed within the space defined by the main element. Unlike block-level elements, they do not begin on new lines.
Some of the inline elements are <a>,<span>,<img>,<code>,<cite>,<button>,<input> etc.
Code Sample with Output:
Note : Block-level elements may contain other block-level elements or inline elements. Inline elements cannot contain block-level elements.
Changes In HTML5
While an understanding of block and inline elements is still relevant, you should be aware that these terms were defined in prior versions of the HTML specification.
In HTML5, a more complex set of “content categories” replaces block-level and inline elements. Block-level elements are largely placed in the “flow content” category in HTML5, while inline elements correspond to the “phrasing content” category.
For more information on the new content categories in HTML5, including flow content and phrasing content, refer to the Content categories page on the Mozilla Developer Network.
Read more about HTML here.
If you read this far, thank the author to show them you care. Say Thanks
Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started
ADVERTISEMENTTừ khóa » Html Block Element Vs Inline
-
HTML Block And Inline Elements - W3Schools
-
Block-level Elements - HTML: HyperText Markup Language | MDN
-
Inline Elements - HTML: HyperText Markup Language | MDN
-
Difference Between Block Elements And Inline Elements
-
Block And Inline Elements
-
CSS Inline Vs Inline-Block Vs Block
-
HTML Block And Inline Elements | Explained - Linux Hint
-
Key Comparisons Between Inline Vs Block - EduCBA
-
HTML Block Vs Inline Elements - YouTube
-
HTML's Block Vs Inline Elements: What They Don't Tell You | Codementor
-
HTML Block Level, Inline Elements - HTML Tutorials - W3resource
-
Inline And Block Elements In HTML - Scaler Topics
-
Conquer CSS By Understanding Inline And Block Level Elements
-
HTML Block And Inline - Free Tutorial To Learn HTML And CSS