HTML element that does not contain formatting

I am constantly modifying text on a webpage using JavaScript. I want text that will match other elements like texts, inputs, etc. Which HTML element should I use? And <div>, and <p>create new lines and other things. <b>does what I want, but it selects all the text. What is the right alternative?

+5
source share
4 answers

<span>tag is the equivalent of a string <div>.

+16
source

<span>

you can also apply a display: inline style to <div>and get similar results

+5

You can apply float, inlineor inline-blockto elements, so that they appear next to other elements. You can also use span.

+5
source

Use the CSS property font-weightso that the element is <b>not bold and retains everything inside the line:

.format {
  font-weight: normal;
}
<b class="format">I am some text</b>
Run codeHide result
0
source

All Articles