How to Remove line breaks for Block Level Elements like div,h1,ul,p tags using CSS in HTML

In this post I will show you how to remove the line breaks or new lines created when we use Block Level Elements like div or Header elements or other tags like ul or paragraph tags etc.


As we all know that
Block Level Elements are HTML Elements that normally start (and end) with a new line when displayed in a browser.

In case our Requirement is that We need no  new lines when using block Lines we go for these CSS scripts

Below is the HTML and CSS Code to achieve
<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        h1,h2,h3,h4,pre {display: inline;}
    </style>
</head>
<body>
       <h1>Hello header1</h1>
          <h2>Hello header2</h2>
          <h3>Hello header3</h3>
          <h4>Hello header4</h4>
          <pre>This is pre code   formatting</pre>
</body>
</html>
Before – Default Alignment
Block Level Elements New Line Removal Default Allignment
Text After the Code



No comments: