Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using <i> vs <span> for icons. #9464

Closed
darrenbkl opened this issue Jun 30, 2016 · 20 comments
Closed

Using <i> vs <span> for icons. #9464

darrenbkl opened this issue Jun 30, 2016 · 20 comments
Labels
help wanted Open for all. You do not need permission to work on these.

Comments

@darrenbkl
Copy link

darrenbkl commented Jun 30, 2016

Using <i> for icon is a not good, fcc shouldn't teach/encourage bad practice, use <span>.

@raisedadead raisedadead added the status: blocked Is waiting on followup from either the Opening Poster of the issue or PR, or a maintainer. label Jun 30, 2016
@raisedadead
Copy link
Member

Can you cite some sources in support of this?

@raisedadead raisedadead changed the title Using <i> for icon is a not good, fcc shouldn't teach/encourage bad practice, use <span>. Using <i> vs <span> for icons. Jun 30, 2016
@darrenbkl
Copy link
Author

darrenbkl commented Jun 30, 2016

<i> is used for italic, <span> is generic, since html does not have tag for icon, span is generally used for such purpose. The use of <i> for icon is semantically incorrect, and might confuse and mislead beginners.

From W3 HTML Language Reference:
The i element represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is italic text; for example, a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, or a ship name.
https://www.w3.org/TR/html-markup/i.html

The span element is a generic wrapper for phrasing content that by itself does not represent anything.
https://www.w3.org/TR/html-markup/span.html

@raisedadead
Copy link
Member

@darrenbkl Thanks for the links, but IMHO those are definitions of <i> and <span> tags.

Can you point us to any resources that state that this not a good practice?

On a side note, this was discussed earlier that the use of <i> is outdated in #7512

/cc @FreeCodeCamp/issue-moderators

@raisedadead
Copy link
Member

@darrenbkl okay here is what I found that may help:

http://stackoverflow.com/questions/11135261/should-i-use-i-tag-for-icons-instead-of-span?answertab=votes#tab-top

Why are they using <i> tag to display icons ?
Because it is:

  • Short
  • i stands for icon (although not in HTML)

Is it not a bad practice ?
Awful practice. It is a triumph of performance over semantics.

Also, I may be wrong but this something which campers will find used everywhere, and I think keeping them aware of the fact that this not standard spec, is used as a common practice is the best we should do and are doing in one of the challenges already.

Refer the issue mentioned in the earlier comment where this is explained.

Do let us know your thoughts.

@ghost
Copy link

ghost commented Jun 30, 2016

@raisedadead, I agree. We should let campers know that this is not good practice, but used all the time. I suggest we just add a sentence in the challenge instructions about this.

@raisedadead
Copy link
Member

@atjonathan as I said its there already #7512 (comment)

And the OP did not mention any other specific challenge that gets affected.

@ghost
Copy link

ghost commented Jun 30, 2016

@raisedadead, sorry didn't see that comment. I think we can close this issue then.

@darrenbkl
Copy link
Author

@raisedadead I don't think it is used in many places.

If it's decided to let member aware of the spec, the challenge should also allows interchangeable use of those tags, i.e. not forcing the use of <i>. Just a thought.

@raisedadead
Copy link
Member

@atjonathan lets wait for OP's comment.
@Bouncey thanks, but the thing is this an argument of semantics vs general practice. Where IMO the later wins.

@raisedadead
Copy link
Member

@darrenbkl Yeah, you are correct indeed. We should allow alternative use. Thanks for reverting.

@raisedadead raisedadead added help wanted Open for all. You do not need permission to work on these. and removed status: blocked Is waiting on followup from either the Opening Poster of the issue or PR, or a maintainer. labels Jun 30, 2016
@raisedadead
Copy link
Member

To contributors:

Change Text Inside an Element Using jQuery needs to be updated with instructions and tests to allow alternative use of <i>

Please comment and share your proposal before making a PR.

@AkiraLaine
Copy link
Member

AkiraLaine commented Jun 30, 2016

@darrenbkl I don't think anyone uses the span tag to display icons. In fact, contrary to what you say, every major icon provider (Font Awesome, Google Icons...etc) uses the i tag for it.

To empathize(italicize) text, you should use the em tag.

@ghost
Copy link

ghost commented Jun 30, 2016

I agree with @AkiraLaine.

@sludge256
Copy link
Contributor

sludge256 commented Jul 6, 2016

Here's Font Awesome's comment on the issue in question,

You can place Font Awesome icons just about anywhere using the CSS Prefix fa and the icon's name. Font Awesome is designed to be used with inline elements (we like the tag for brevity, but using a is more semantically correct).

http://fontawesome.io/examples/

We should definitely allow the use of the span tag though.

@AryanJ-NYC
Copy link
Contributor

@dhcodes
Copy link
Contributor

dhcodes commented Aug 6, 2016

I'm working on this one. Will have a PR in later today.

@sagayev
Copy link

sagayev commented Feb 6, 2017

This was accepted:
<button class="btn btn-block btn-primary"><i class="fa fa-thumbs-up">Like</i></button>

But this was not:
<button class="btn btn-block btn-primary fa fa-thumbs-up">Like</button>

Although they yield the same result. I am newbie here. I don't know if the latter has any side effect..

@raisedadead
Copy link
Member

@sagayev please open a new issue.

@Mielai1l
Copy link

Mielai1l commented Mar 21, 2017

the challenges mentioned by AryanJ-NYC on 5 Aug 2016 are not yet updated
https://www.freecodecamp.com/challenges/add-font-awesome-icons-to-our-buttons
https://www.freecodecamp.com/challenges/add-font-awesome-icons-to-all-of-our-buttons
challenges building further like https://www.freecodecamp.com/challenges/responsively-style-radio-buttons are also using the tag.

@erictleung
Copy link
Member

@Mielai1l they've been changed in the codebase. You can see for yourself in the beta site. Changes will be pushed to the production site soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Open for all. You do not need permission to work on these.
Projects
None yet
Development

No branches or pull requests

9 participants