0

How can I format this object output to be horizontally listed instead of vertical?

for(var i=0; i<a; i++){
$('#{STORIES.story_id}6').append($('<div>', {text: sound[i].title}));

1 Answer 1

1

This is not so much a JavaScript question than it is a HTML/CSS question. The output is vertical is most likely due to the use of <div> tag. It is a block level element, therefore there will always be space before and after this element. (Read more about block vs inline here: http://www.impressivewebs.com/difference-block-inline-css/ )

Try using an inline element. Eg. <span>

Keep in mind that in order to be valid markup, any inline level element must be contained in a block level element. Edit: To clarify, you can't have a block level element inside an inline level element.

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

2 Comments

Why? An in-line element (such as a span) can appear within another in-line element, such as a span, or an a.
An inline element can be in an inline element. That's fine, but one of its ancestors must be a block element. The good news is that <body> and <html> are both block level.

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.