/_posts/2015-03-03-html-inline-semantics.md

https://gitlab.com/jnettome/marksheet · Markdown · 91 lines · 67 code · 24 blank · 0 comment · 0 complexity · 19e9c30ada9536084e7f890cc03e381b MD5 · raw file

  1. ---
  2. layout: post
  3. title: "<strong>Inline</strong> semantics"
  4. subtitle: "The small parts <em>within</em> a block of text"
  5. section: html
  6. ---
  7. While paragraphs and lists are meant to identify whole **blocks** of text, we sometimes want to provide meaning to a word (or a few words) _within_ a text.
  8. ### Strong
  9. For **important** words, use the `<strong>` tag:
  10. {% highlight html %}
  11. <p>
  12. This is <strong>important</strong> but this is not.
  13. </p>
  14. {% endhighlight %}
  15. <div class="result">
  16. <p>
  17. This is <strong>important</strong> but this is not.
  18. </p>
  19. </div>
  20. By default, `<strong>` elements are displayed in **bold**, but keep in mind that it is only the browser's default behavior. Don't use `<strong>` _only_ to put some text in bold, but rather to give it more **importance**.
  21. ### Emphasis
  22. For _emphasized_ words, use the `<em>` tag:
  23. {% highlight html %}
  24. <p>
  25. This is <em>emphasized</em> but this is not.
  26. </p>
  27. {% endhighlight %}
  28. <div class="result">
  29. <p>
  30. This is <em>emphasized</em> but this is not.
  31. </p>
  32. </div>
  33. By default, `<em>` elements are displayed in _italic_, but keep in mind that it is only the browser's default behavior. Don't use `<em>` _only_ to put some text in italic, but rather to give it _stress emphasis_.
  34. ### Abbreviations
  35. Abbreviations like W3C or CD can use the `<abbr>` element:
  36. {% highlight html %}
  37. <p>
  38. I just bought a <abbr>CD</abbr>.
  39. </p>
  40. {% endhighlight %}
  41. You can add a `title` **attribute** to specify the abbreviation's description, which will appear by hovering the element:
  42. {% highlight html %}
  43. <p>
  44. I just bought a <abbr title="Compact Disc">CD</abbr>.
  45. </p>
  46. {% endhighlight %}
  47. <div class="result">
  48. <p>
  49. I just bought a <abbr title="Compact Disc">CD</abbr>.
  50. </p>
  51. </div>
  52. ### Inline quotes
  53. The `<blockquote>` element is a **block-level** element. It has an **inline** version: `<q>`:
  54. {% highlight html %}
  55. <p>
  56. He said <q>Hello World</q> and just left.
  57. </p>
  58. {% endhighlight %}
  59. <div class="result">
  60. <p>
  61. He said <q>Hello World</q> and just left.
  62. </p>
  63. </div>
  64. ### Other inline elements
  65. There are plenty of other [inline semantic elements](https://developer.mozilla.org/en/docs/Web/HTML/Element#Inline_text_semantics) to choose from, but we've covered the most common ones.
  66. *[CD]: Compact Disc
  67. *[W3C]: World Wide Web Consortium