Open In App

How to display paragraph elements as inline using CSS ?

Improve
Improve
Like Article
Like
Save
Share
Report

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:

HTML




<!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:

  • Google ChromeInternet Explorer
  • Firefox
  • Opera
  • Safari


Last Updated : 05 Nov, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads