Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to prevent linebreak after H2 tags?

Tags:

html

css

I'd like to display something on the same line but keep the H2 tag (just so I don't have to change it in a bunch of different places). Can this be done using CSS?

like image 207
Abe Miessler Avatar asked Aug 25 '10 15:08

Abe Miessler


People also ask

How do you prevent line breaks?

There are several ways to prevent line breaks in content. Using   is one way, and works fine between words, but using it between an empty element and some text does not have a well-defined effect. The same would apply to the more logical and more accessible approach where you use an image for an icon.

How can we prevent h1b from New Line?

Use white-space:nowrap; to achive what you are looking for.

How do you prevent a line break in CSS?

The white-space property has numerous options, all of which define how to treat white space inside a given element. Here, you have set white-space to nowrap , which will prevent all line breaks.

How do you not have a line break in HTML?

The <nobr> HTML element prevents the text it contains from automatically wrapping across multiple lines, potentially resulting in the user having to scroll horizontally to see the entire width of the text.


2 Answers

Try adding the CSS h2 { display: inline }.

like image 151
Deniz Dogan Avatar answered Nov 06 '22 21:11

Deniz Dogan


Try:

h2 {
  display:inline;
}
like image 41
fredley Avatar answered Nov 06 '22 19:11

fredley