I have this simple snippet in a WordPress widget:
<h3>Kevin Smith</h3><h2>The Official Kevin Smith Website</h2>
The name is changed for privacy. Is there any possible way I get get these to appear on the same line?
I'm a CSS dummy, but I've tried doing things like:
<div display:inline><h3>Kevin Smith</h3><h2>The Official Kevin Smith Website</h2></div>
But this doesn't work for reasons that are most likely obvious to CSS gurus.
Any guidance in how I can achieve putting these on the same line would be greatly appreciated!
* UPDATED SOLUTION *
For anybody with similar issues, I just used this -- with the help of @antyrat and @jacefarm:
<div style="display:inline">Kevin Smith</div><p style="display:inline">The Official
Kevin Smith Website</p>
That way, I was able to style the div differently than the p, and they're both inline -- which is precisely what I was attempting to achieve.
The easiest way to use this type of formatting is to type your heading text followed by your body text, in a single paragraph. Make sure the entire paragraph is formatted as body text, then select just the text that will comprise the heading. Apply the level-three heading style to this selected text.
An inline element does not start on a new line. An inline element only takes up as much width as necessary. This is a <span> element inside a paragraph.
div is a “block element” (now redefined as Flow Content) and span is an “inline element” (Phrasing Content).
Inline styles on HTML elements are written as HTML attributes. You would use the 'style' attribute and give it a value that is wrapped in quotes. Also, you need to have a semi-colon after each CSS '[property]: [value];' pair passed into the 'style' attribute, just like you would in a standard CSS stylesheet.
<div>
<h3 style="display: inline;">Kevin Smith</h3>
<h2 style="display: inline;">The Official Kevin Smith Website</h2>
</div>
Alternatively, you could assign a class to the parent 'div' element, such as 'title', and then style the 'h3' and 'h2' tags in your CSS stylesheet, like this:
HTML
<div class="title">
<h3>Kevin Smith</h3>
<h2>The Official Kevin Smith Website</h2>
</div>
CSS
.title h2,
.title h3 {
display: inline;
}
You need to use style
attribute:
<div style="display:inline">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With