Open In App

How to display paragraph elements as inline using CSS ?

The purpose of this article is to display paragraph elements as inline elements using CSS. The display property in CSS is used for placing the components (“div”, “hyperlink”, “heading”, etc) on the web page. The display property is set to inline. It has the default property of “anchor” tags. It is used to place the “div” inline i.e. in a horizontal manner. The inline option of display property ignores the “width” and “height” set by the user.

Syntax:



display: inline; 

Example:




<!DOCTYPE html>
<html>
  
<head>
    <style>
        #main {
            height: 200px;
            width: 200px;
            background: teal;
            display: inline;
        }
  
        #main1 {
            height: 200px;
            width: 200px;
            background: cyan;
            display: inline;
        }
  
        #main2 {
            height: 200px;
            width: 200px;
            background: green;
            display: inline;
        }
  
        .gfg {
            margin-left: 20px;
            font-size: 42px;
            font-weight: bold;
            color: #009900;
        }
  
        .geeks {
            font-size: 25px;
            margin-left: 30px;
        }
  
        .main {
            margin: 50px;
        }
    </style>
</head>
  
<body>
    <div class="gfg">GeeksforGeeks</div>
    <h2>
        How to display paragraph elements 
        as inline elements using CSS?
    </h2>
      
    <p class="main">
    <p id="main"> BLOCK 1 </p>
    <p id="main1"> BLOCK 2</p>
    <p id="main2">BLOCK 3 </p>
    </p>
</body>
  
</html

Output:



Supported browsers are listed below:


Article Tags :