Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap and HTML5 Semantic tags

I am getting started with Twitter Bootstrap and came across a question.

Recently went through some tutorials regarding HTML5 and found out about semantic elements such as header, nav, footer, etc should be used instead of Div.

Now, while learning Bootstrap most of them are using Div tag.

So Which is the good approach Bootstrap Div tags or HTML5 Semantic Tags and Why?

Thanks.

like image 781
Jatin Avatar asked Mar 02 '14 21:03

Jatin


People also ask

What are the HTML5 semantic tags?

Semantic HTML elements are those that clearly describe their meaning in a human- and machine-readable way. Elements such as <header> , <footer> and <article> are all considered semantic because they accurately describe the purpose of the element and the type of content that is inside them.

Which HTML used semantic tags?

HTML 5 introduced new semantic elements such as section , article , footer , progress , nav , aside , mark , and time .

What are semantic tags?

The HTML semantics refers to the tags that provide meaning to an HTML page rather than just presentation. It makes HTML more comprehensible by better defining the different sections and layout of web pages.

What is the semantic difference between HTML tag and HTML text?

Semantic HTML or semantic markup is HTML that introduces meaning to the web page rather than just presentation. For example, a <p> tag indicates that the enclosed text is a paragraph. This is both semantic and presentational because people know what paragraphs are, and browsers know how to display them.


1 Answers

Bootstrap use Divs to show how the framework should be used. This is because divs are general block element that can be used in almost every cases for containers. But the element you are using with bootstrap doesn't matter for styling, because bootstrap uses classes to apply styles to the elements (except for tables which are partially stylised with tagnames).

For example, you will have the same result on screen when using :

<section class="col-md-4">Hello</section> 

than when using

<div class="col-md-4">Hello</div> 

The real difference will be for robots and accessibility readers because as you said, HTML5 elements are semantics.

Each developer will choose the element that he feels most comfortable with. But my point of view is : if you trust the semantical approach of html5 elements (and you should :) ) the best way would be to use html5 elements for tag that have a special meaning (like header, footer, nav, ...) and use div for all cases in which no html5 element exist.

Here is a list of all elements with their meanings : https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_element_list

like image 130
ylerjen Avatar answered Sep 20 '22 11:09

ylerjen