Quantcast
Channel: HTML – Code Chewing
Viewing all articles
Browse latest Browse all 21

Preparing page elements for HTML5

$
0
0

Get HTML5 elements to act as normal divs in HTML5 unsupported browsers

HTML5 elements are supposed to create cleaner markup, such examples are <header>, <section>, <nav> and <footer>.

To ensure these elements work in browsers not supporting these HTML5 elements, you need to use the correct HTML5 DOCTYPE:

<!DOCTYPE html>

Then a bit of JavaScript to ensure these elements are treated as block-level elements (Primarily for Internet Explorer’s benefit):

<script type="text/javascript>
  document.createElement('header');
  document.createElement('section');
  //... and so on...
</script>

And when styling the elements with CSS, ensure to add display:block too:

header,
section,
nav,
footer {
  display:block;
}

Viewing all articles
Browse latest Browse all 21

Trending Articles