Scope attribute general question


In Learn HTML: Tables, step 5 of 13. There is mention of using the scope attribute. I’m wondering what the significance is of doing so. If the table heading has a title associated with it shouldn’t it already show up in the proper place? for example.



  <th scope= "row">Question</th>

It looks like these two display the code in the same way, so I’m wondering why we add the scope attribute (my guess is it makes something easier that we learn about late on) and whether I should just adopt it as best practice?


I realize my code actually worked within my question… how can I display the code I used without it actually reflecting in my message?


thankfully we have documentation for that:


This looks like a great resource and I’ve gone ahead and bookmarked it! Thank you for that. I guess it doesn’t really answer my question though. It could be due to a lack of knowledge much beyond this point as it relates to coding, but I guess my question relates more to why we would use the scope attribute as opposed to just using my first example as the output appears to be the exact same. In this case if the best answer is “You’ll learn why later”. I’m actually perfectly fine with that response.


MDN is a great resource for anything related to html, css and JS.

from w3c:

The objective of this technique is to associate header cells with data cells in complex tables using the scope attribute. The scope attribute may be used to clarify the scope of any cell used as a header.

they give a good example:

 <table border="1">
  <caption>Contact Information</caption>
    <th scope="col">Name</th>
    <th scope="col">Phone#</th>
    <th scope="col">Fax#</th>
    <th scope="col">City</th>
    <th scope="row">Joel Garner</th>
    <th scope="row">Clive Lloyd</th>
    <th scope="row">Gordon Greenidge</th>

using scope can help machines to much better understand your table


I think this is what I needed to see to help it make sense. I appreciate your help!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.