Editing 1144: Tags

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 40: Line 40:
 
The rules of proper nesting also put restrictions on which tags can be placed where — "block" elements, such as <code>&lt;div&gt;</code> cannot be placed inside "inline" elements, such as <code>&lt;span&gt;</code>, and inline elements must be placed inside a block element of some kind. Thus, <code>&lt;span&gt;&lt;div&gt;</code> is forbidden, even if the tags are closed in the proper order.
 
The rules of proper nesting also put restrictions on which tags can be placed where — "block" elements, such as <code>&lt;div&gt;</code> cannot be placed inside "inline" elements, such as <code>&lt;span&gt;</code>, and inline elements must be placed inside a block element of some kind. Thus, <code>&lt;span&gt;&lt;div&gt;</code> is forbidden, even if the tags are closed in the proper order.
  
Further, web developers make a distinction between ''semantic'' and ''structural'' elements. Semantic elements contain a clue in their name as to what kind of an element they are — for example, an <code>&lt;article&gt;</code> tag contains an article, such as a blog post or news article, while an <code>&lt;ol&gt;</code> tag contains an '''o'''rdered '''l'''ist. (It's wise to note that this is not an absolute rule; it's ''possible'' to put non-article content in an <code>&lt;article&gt;</code>, it's just not recommended.) Semantic tags do not, however, indicate how their contents are to be displayed; your browser might display an <code>&lt;article&gt;</code> in the default font, layout, and placement, while mine, a {{w|screen reader}}, might ignore everything on the page except <code>&lt;article&gt;</code>s.
+
Further, web developers make a distinction between ''semantic'' and ''structural'' elements. Semantic elements contain a clue in their name as to what kind of an element they are — for example, an <code>&lt;article&gt;</code> tag contains an article, such as a blog post or news article, while an <code>&lt;ol&gt;</code> tag contains an '''o'''rdered '''l'''ist. (It's wise to note that this is not an absolute rule; it's ''possible'' to put non-article content in an <code>&lt;article&gt;</code>, it's just not recommended.) Semantic tags do not, however, indicate how their contents are to be displayed; your browser might display an <code>&lt;article&gt;</code> in the default font, layout, and placement, while mine, a {{w|screen reader}}, might ignore everything on the page except <code>&lt;article&gt;</code>s, and read <code>&lt;article&gt;</code>s in a [[462|soothing voice]].
  
 
Structural tags, on the other hand, give no clues as to what they contain; they just indicate how a web page is to be laid out. <code>&lt;span&gt;</code> and <code>&lt;div&gt;</code> are structural tags; they can contain anything. Their definitions in HTML simply indicate that <code>&lt;div&gt;</code> is a block tag (it can affect both what the text looks like and where it is on the page; by default, it is displayed in a separate block from the rest of the text in the page, and has at least one line break before and after its display) and <code>&lt;span&gt;</code> is an inline tag: it affects what its text looks like, but not where it is on the page. Without additional attributes, it's impossible for a browser to tell what's supposed to be inside a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code>, which means that my screen reader can't just pluck out the blog posts and read those.
 
Structural tags, on the other hand, give no clues as to what they contain; they just indicate how a web page is to be laid out. <code>&lt;span&gt;</code> and <code>&lt;div&gt;</code> are structural tags; they can contain anything. Their definitions in HTML simply indicate that <code>&lt;div&gt;</code> is a block tag (it can affect both what the text looks like and where it is on the page; by default, it is displayed in a separate block from the rest of the text in the page, and has at least one line break before and after its display) and <code>&lt;span&gt;</code> is an inline tag: it affects what its text looks like, but not where it is on the page. Without additional attributes, it's impossible for a browser to tell what's supposed to be inside a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code>, which means that my screen reader can't just pluck out the blog posts and read those.

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)