Why should we use tags like p, span, hx tags when we can use CSS instead? Is it important from an SEO point of view?
|
The short version is that that the various tags and CSS have different purposes.
You can't dismiss the semantic tags based on what you can do with CSS, and vice versa. |
||||
|
|
|
Firstly, Nextly, while stylesheets are great, some devices will ignore stylesheets and focus only on the HTML, which is where a tag like
Sure, we can say that HTML was not meant to be for styling, but there is a delicate line between design and style; and frankly, I'd say consider that to be user preference. Whether you use |
||||
|
|
|
Also: do not forget the importance of the semantics for users with a disability. Screenreader software depends on these semantics to present blind people the required context they're missing out on because of their disability. |
|||
|
|
Markup and presentation are differentThis is a bit like asking "why should we have walls when we have paint?" :) HTML tags denote what your content is - this is a headline, this is a list, etc. CSS denotes what your content should look like - headlines should be blue, lists should be indented this much, the menu should be on the left, etc. Javsascript tells how your page should behave - animations, etc. So, without HTML content, CSS and Javascript really have nothing to work on. These categories are not 100% black and white - for example, CSS can specify "transitions" now, which are animations - but they're the basic idea. Please see previous discussions on this topic on StackOverflow here and here. How good markup impacts SEOFundamentally, SEO is about convincing search engines that your content is the best match for a search term. Obviously, nobody at Google is personally reading every web page and ranking it. Therefore, for search engines to know what your content is, a program has to parse it. And hey, look! We have this whole language called HTML that's meant to label your content in a way that machines can understand! :) So yes, clear markup will help search engines to index your pages better. To use an extreme example, if your page's headline was actually a photograph that you took of a newspaper headline, it might look interesting, and people could read it just fine, but to a search engine, it would just be an image with no meaning. Whereas |
|||||||||||||
|
|
Please also think about people with some sort of impairment who (as an example) have to use a braille reader. In such cases the html tags are of far greater importance than the visual css stylings. |
||||
|
|
|
For HTML5, check out bold and italic in HTML5. Summary:
|
|||||||||||||||||||||
|
|
Su answered the semantic portion. With regards to SEO, you'll find that the h1 element is given more weight by search engines than other tags. The h2/b/strong tags are given a little more weight than regular text. Most other tags are pretty much equal, but you should always use the most appropriate tag for the job. Google has recently begun parsing tables when used for tabular data, and other appropriately-used HTML can give signals to which content is more important than others. |
|||||||||||||
|
<span>for everything and see whether you can accomplish what you want with CSS alone. You'll likely learn a lot from trying to target the right spans and make them behave like other elements. (Though the likeliest lesson is "don't do that.") – Nathan Long Nov 21 '12 at 17:44