0

I saw that there are many questions looking like this one but can't find a solution yet.

My HTML code:

<p class="ref" style="display:inline">
<p class="mini-caps">albums</p>: 
  Scum
  (1987) ; 
  Bootlegged in Japan
  (1998)
</p>
<p class="ref">
<p class="mini-caps">compilation </p>: 
  Noise for Music’s Sake 
  (2 CD, 2003)
</p>
<p class="ref">
  <p class="mini-caps">album</p>: 
  Illmatic 
  (1994)
</p>

I tried to style p.ref with display:inline with no success.

The output I would like to have:

albums : Scum (1987) ; Bootlegged in Japan (1998)

compilation : Noise for Music’s Sake (2 CD, 2003)

album : Illmatic (1994)

5
  • inline on all the mini-caps Commented Jul 5, 2018 at 14:14
  • 3
    Nested paragraphs are not valid, and it's generally not advisable to make block-level elements inline. Just use spans. Commented Jul 5, 2018 at 14:27
  • I looked at your question again and can't glean your intent. You seem to have an XY problem happenin'. Why are you not just using basic, unstyled paragraphs for each item? If you want to group them for styling, wrap the album and compilation paragraph pairs in a div. Commented Jul 5, 2018 at 14:44
  • The thing is that I need to copy the layout/display of an existing book in HTML. And I need to add style to different elements in order to do that. But I try with little iterations/tests without knowing if it's the good way or not since I didn't practice so much HTML/CSS. Commented Jul 5, 2018 at 15:01
  • 1
    You can’t actually nest the p elements, at least in HTML mode: they are auto-closed before opening tag of any non-phrasing element (“block element” in HTML4 terms) and the next paragraph ends up being a sibling of the previous one, not its child. Don’t rely on the markup you write, always check the DOM that browser constructs from it. Also, see stackoverflow.com/questions/11570902/… Commented Jul 5, 2018 at 15:47

1 Answer 1

1

why the use of the p tags? You can properly do this with div's and span's.

<div class="ref">
    <span class="mini-caps">albums</span>: 
    <span>Scum (1987) ; Bootlegged in Japan (1998)</span>
</div>
<div class="ref">
    <span class="mini-caps">compilation </span>: 
    <span>Noise for Music’s Sake (2 CD, 2003)</span>
</div>
<div class="ref">
    <span class="mini-caps">album</span>: 
    <span>Illmatic (1994)</span>
</div>

See https://jsfiddle.net/1r9Lu6y3/6/

Hope this helps

BTW: Illmatic album is sooo good!

Sign up to request clarification or add additional context in comments.

3 Comments

Frankly a dl/dt/dd structure might be ideal - developer.mozilla.org/en-US/docs/Web/HTML/Element/dl
@KSoze your welcome. Regarding your question could have a code example? I'm not quite following.
@NickVanLoocke sorry I deleted my comment, it's working fine finally :) Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.