homepage Welcome to WebmasterWorld Guest from 54.227.12.219
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Should There Be a Space Before </li>
gouri




msg:4577772
 6:00 pm on May 25, 2013 (gmt 0)

I am using XHTML 1.0 Transitional and saw coding for lists in two ways.

One way has a space before the </li> tag begins and one does not. Which is the proper way to write this?

<ul>
<li>I went to the park. </li>
<li> I went to the mall. </li>
</ul>

or

<ul>
<li>I went to the park.</li>
<li> I went to the mall.</li>
</ul>

Should I leave a space before the < in </li> and the . at the end of the sentence? Is either way okay?

I would appreciate your thoughts.

 

birdbrain




msg:4577775
 6:06 pm on May 25, 2013 (gmt 0)

Hi there gouri,

I would not leave any spaces, either after the opening
tag or before the closing tag.

If spacing is required, then use precise CSS padding to
achieve it.

birdbrain

gouri




msg:4577783
 6:31 pm on May 25, 2013 (gmt 0)

@birdbrain,

Thanks for the response.

So you would go with the second one. That one is coded the way that it should be?

birdbrain




msg:4577784
 6:46 pm on May 25, 2013 (gmt 0)

Hi there gouri,

It is not really a case of right or wrong. :)

A space before the closing tag makes no difference to the outcome,
whereas a space after the opening tag will indent the text.

By habit, I don't leave space on either side. ;)

birdbrain

drhowarddrfine




msg:4577789
 7:53 pm on May 25, 2013 (gmt 0)

What is your reasoning for putting a space in? At one time, in certain situations, IE would mess up formatting and a space would fix that but I don't recall if that's still true. At least, I've not run into it lately.

Why are you using XHTML or transitional?

lucy24




msg:4577793
 8:13 pm on May 25, 2013 (gmt 0)

a space after the opening tag will indent the text

This depends on the browser. A "conforming user-agent" may choose to ignore any whitespace after any opening tag, along with any whitespace before any closing tag. Useful to know if you habitually use inverse markup, like <i>switching italics </i>off<i> and on again</i>. (You shouldn't be doing this anyway, but it can occur. Yes, I intentionally used html markup rather than Forums markup.)

gouri




msg:4577831
 12:22 am on May 26, 2013 (gmt 0)

Thanks for the responses, everyone.

@drhowarddrfine,

What is your reasoning for putting a space in?

Do you mean the space before </li> ? I saw both ways (with a space and without) on the Internet, and I was trying to figure out what is the proper way to code the bullet points.

Why are you using XHTML or transitional?

That's what the template uses. What would you recommend using?

g1smd




msg:4577835
 1:11 am on May 26, 2013 (gmt 0)

Many would recommend HTML 4.01 Strict or HTML 5.

gouri




msg:4577847
 2:27 am on May 26, 2013 (gmt 0)

Thanks for the recommendations, gs1md.

Can you tell me why these would be better?

drhowarddrfine




msg:4577853
 3:17 am on May 26, 2013 (gmt 0)

@gouri Transitional doctypes were created for those transitioning from older, obsoleted HTML back in 1999 to HTML4. New web pages should never be using obsolete markup. You should always be in strict mode.

While HTML4.01 strict doctype is fine, the idea is to keep the browser in strict mode and the newer, so-called "HTML5 doctype" does just that. Plus it's a lot shorter and easier to remember. Also note, there is no "5" in this doctype as it really has nothing to do with the version number:
<!DOCTYPE html>
While I capitalized doctype, it's not necessary with HTML5 though that breaks from every other standard that requires it to be capitalized.

gouri




msg:4579701
 2:19 am on May 31, 2013 (gmt 0)

Thanks for the explanation and telling me how to write the DOCTYPE.

kishor insight




msg:4580893
 5:16 am on Jun 4, 2013 (gmt 0)

I would not leave any spaces, either after the opening
tag or before the closing tag.

If spacing is required, then use precise CSS padding to
achieve it.

[edited by: incrediBILL at 6:02 am (utc) on Jun 4, 2013]
[edit reason] Removed SIG see TOS [/edit]

Mike Spancer




msg:4584175
 12:12 pm on Jun 14, 2013 (gmt 0)

Spaces are not used in HTML tags either opening tag or closing.

-Mike

gouri




msg:4584247
 3:37 pm on Jun 14, 2013 (gmt 0)

I appreciate the responses.

Dether




msg:4637061
 12:19 pm on Jan 13, 2014 (gmt 0)

More than one space doesn't matter. And you should code in that way to have readable code. To do some spacing and view modifications use css.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved