Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Wednesday, June 22, 2016

How do I align an h3 with a p without creating two separate lines?

How do I align an h3 with a p without creating two separate lines?


I have html code that looks like this:

Corruption, the most infallible symptom of constitutional liberty.

~ Edward Gibbon

The resulting output is below:

enter image description here

As I pointed out w/ the arrow, I don't want Edward Gibbon below the quote, but preferably to the right of "liberty".

Is this possible, if I have h3 tags involved? Should I be using span or div tags? Any guidance would be greatly appreciated!


Updated solution in case anybody needs this in the future (via Greg Jennings):

Corruption, the most infallible symptom of constitutional liberty. ~ Edward Gibbon

The resulting output is below:

enter image description here

Answer by Greg Jennings for How do I align an h3 with a p without creating two separate lines?


Use a span inside the tag with the style you want. You need an inline element here.

Corruption, the most infallible symptom of constitutional liberty. ~ Edward Gibbon

Answer by Toan Nguyen for How do I align an h3 with a p without creating two separate lines?


You can change the display type of the p and h3 tags

HTML:

Corruption, the most infallible symptom of constitutional liberty.

~ Edward Gibbon

CSS:

  

Answer by azes for How do I align an h3 with a p without creating two separate lines?


is a block element, it will use all the available width. You could use a span inside the h3 instead of the p. Or you could replace the h3 with an inline element.

Answer by Eru Penkman for How do I align an h3 with a p without creating two separate lines?


Just make them inline!

h3, p{       display: inline;  }   

Note, you probably don't want this to affect all p's and h2's so i'd do this:

blah balh

blah

CSS:

.same-line p, .same-line h2{      display:inline;  }  

Answer by setek for How do I align an h3 with a p without creating two separate lines?


You should use the correct tools for the job.

This is a quote, it belongs in a blockquote:

http://jsfiddle.net/2a2S9/

HTML:

Corruption, the most infallible symptom of constitutional liberty.

CSS:

blockquote { font-weight: bold;      font-size: 20px; }    blockquote p { display: inline-block; }    blockquote p.byline { font-weight: normal;      font-size: 12px; }  

Answer by Vishwa Parekh for How do I align an h3 with a p without creating two separate lines?


p {     display:inline;   float:none;    }  

Answer by Sarath for How do I align an h3 with a p without creating two separate lines?


try the following css

h3,p{       float:left;      width:auto;  }   


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.