How to position DIV in text

Asked

Viewed 41 times

1

I am trying to put a DIV in the same line of text, when I run the HTML below, the DIV is at the bottom line of the text.

<html>
<head>
<style>
    div {
  width: 10px;
  height: 10px;
  border: 1px solid black;
  padding: 2px;
  margin: 10px;
}
</style>
</head>
<body>
<p>
posicionar essa div <div></div> na mesma linha
</p>
</body>
</html>

How do I get this DIV to stay on the same line as the text to form only one line?

2 answers

2


Here’s an example using your code.

<html>
<head>
    <style>
        div {
            display: inline-block;
            width: 10px;
            height: 10px;
            border: 1px solid black;
            padding: 2px;
            margin: 10px;
        }
    </style>
</head>
<body>
    <span> posicionar essa div <div></div> na mesma linha</span>
</body>
</html>

1

There is a CSS property, display: inline-block;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.