When defining content and presentation, see the HTML document as a data container. Then ask yourself about each element and attribute:
Is an attribute / element a significant object in my data?
For example, are the words between the <b> tags in bold just for display purposes, or do I want to add emphasis to this data?
Am I using the correct attribute / element for a property that represents the type of data I want to represent?
Since I want to add emphasis to this particular section, I have to use <em> (this does not mean italics, it means highlighting and can be shown in bold) or <strong> depending on the desired level of attention.
Do I use the attribute / element for display only? If so, can I remove the element and the parent element using CSS?
Sometimes a presentation tag can simply be replaced by CSS rules with a parent element. In this case, you must remove the presentation tag.
By asking yourself these three simple questions, you can usually make an informed decision. Example:
Original code: <label for="name"><b>Name:</b></label>
Checking the <b> ...
Is an attribute / element a significant object in my data?
No, the tag does not represent node data. It is just for presentation.
Am I using the correct attribute / element for a property that represents the type of data I want to represent?
<b> used to represent bold elements.
Do I use the attribute / element for display only? If so, can I remove the element and the parent element using CSS?
Since <b> is presentation, and I use it for presentation, yes. And since the <b> element affects the entire <label> , it can be deleted, and the style will be applied to the <label> .
The goal of semantic HTML is not to simplify design and redesign or to avoid inline style, but to help the parser understand what this tag is in your document. In this way, applications can be created (i.e.:: search engine) to intelligently decide what your content means and classify it accordingly.
Therefore, it makes sense to use the CSS content: property to add quotes around the text located in the <q> (it does not matter for the data contained in your document, the other that it represents), but it does not make sense to use one and the same same CSS property to add the Β© symbol to the footer as it matters in your data.
The same goes for attributes. Using the width and height attribute in the <img> tag representing a 16x16 icon makes semantic meaning, since it is important to understand the meaning of the <img> (the icon may have different representations depending on the size it is displayed in). Using the same attributes in an <img> tag representing a thumbnail of a larger image does not work.
Sometimes you need to add non-semantic elements in order to be able to achieve the desired presentation, but usually this can be avoided.
There are no wrong items. There are misuse of certain elements. <b> should not be used when adding emphasis. <small> should be used for legal subtext, and not for reducing text (see HTML5 - section 4.6.4 ) ... All elements have a specific use case and they all represent data (minus presentation elements, but in some cases they are used ) No items should be put off.
Attributes are another matter. Most attributes are characteristic. Attributes such as <img border> and <body fgcolor> rarely matter in the data you represent, so you should not use them (except in those rare cases).
Search engines are a good example of why semantic documents are so important. Microformats are a predefined set of elements and classes that you can use to represent data that search engines will understand in a certain way. Product pricing information on Google Search is an example of semantics at work.
Using predefined rules in established standards for storing information in your document, a third-party program can understand what looks like a wall of text without using heuristic algorithms that may be error prone. It also helps screen readers and other accessibility applications more easily understand the context in which the information is presented. It also helps a lot with the maintainability of your markup, as it is all about defining a set.