How to Add Spaces Using Div in Html

I want to add spaces between two widgets. Please tell me an inline div code to add a space of around 300px. I have used this code:

<div style="width:300px"></div> 

but I couldn't see 300px gap between the two widgets.

How to add this much gap between those widgets?

1

2 Answers

Check this example , if you are keeping the div empty you need to give it a height than only it will occupy the space .

.div1{width:200px;background:#ddd;height:200px;display:inline-block}
.div2{width:200px;background:red;height:200px;display:inline-block}
.gap{width:200px;background:none;height:200px;display:inline-block;}
<div class='div1'></div><div class='gap'></div><div class='div2'></div>

edit: removed solution that had already been tried but was not yet in the question

Pure HTML:

<div></div>&nbsp;&nbsp;&nbsp;

Note that &nbsp; represents a single space, so keep adding them until you have enough. Note that this is an extremely crude and not-recommended solution. For a pure CSS solution, see the demo.

edit: here is a demo

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest