jQuery Selectors: Selects elements that are of header type

This entry is part 29 of 33 in the series jQuery Selectors

$(‘:header’)

Selects elements that are of header type such as <h1>,<h2>,<h3> and so on.

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML5</title>
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
    <script>
        $(function () {
            $(':header').css('background-color', 'yellow');
        });
    </script>
</head>
<body>

<article>
    <header>
        <h1>Ushuaia</h1>

        <p>Ushuaia is the capital of Tierra del Fuego in Argentina</p>
    </header>
    <section>
        <p>It is commonly regarded as the southernmost city in the world.</p>

        <p>They also built a railway now a tourist attraction known as the End of the World Train</p>
    </section>
</article>

</body>
</html>

HTML5: Multiple <header> on one page

This entry is part 8 of 34 in the series HTML5

We can have multiple headers and they do not have to be at the top of the page.

All the headers are nested under the article tags.

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML 5</title>
</head>
<body>

<article>
    <header>
        <h1><a href="#">American Rock</a></h1>

        <p>17.05.2014</p>
    </header>
    <p>The end of the world as we know it.</p>
</article>

<article>
    <header>
        <h1><a href="#">British Pop</a></h1>

        <p>16.05.2014</p>
    </header>
    <p>Just can't get enough.</p>
</article>

<article>
    <header>
        <h1><a href="#">Heavy Metal</a></h1>

        <p>15.05.2014</p>
    </header>
    <p>Enter the sandman.</p>
</article>

</body>
</html>

HTML5: Using the <header> element for site header

This entry is part 6 of 34 in the series HTML5

The <header> element is usually the first thing on the body of a web page.

It can contain logo, website name or site navigation.

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title></title>
</head>
<body>

<header>
    <hgroup>
        <h1>Learning HTML5 </h1>

        <h3>It's easy to learn HTML5 with Codecrawl!</h3>
    </hgroup>
</header>

</body>
</html>

The hgroup here is used to group the heading and the sub heading.

jQuery Mobile: Navigation bar and header in swatch b

This entry is part 55 of 73 in the series jQuery Mobile

As a navigation bar, it might actually be better to use a different theme to differentiate it from the rest of the page.

A swatch is a combination or a collection of colors.  When they are combined together, it becomes a theme.

Here we use swatch b for the header and the navigation bar.

Navigation Bar
DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js'></script>
    <title>Upwhere</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header' data-theme='b'>
        <h1>Welcome To My Mobile App</h1>
    </div>
    <div class='ui-body-b ui-body'>
        <div data-role='navbar'>
            <ul>
                <li><a href='#' data-icon='grid'>A</a></li>
                <li><a href='#' data-icon='star'>B</a></li>
                <li><a href='#' data-icon='gear'>C</a></li>
                <li><a href='#' data-icon='arrow-l'>D</a></li>
                <li><a href='#' data-icon='arrow-r'>E</a></li>
            </ul>
        </div><!-- /navbar -->
    </div>

    <div data-role='content'>
        <p>You can put your content here...</p>
    </div>

    <div data-role='footer' data-position='fixed'>
        <h4 style='text-align:center;'>I'm the footer</h4>
    </div>
</div>

</body>
</html>
Try The Code

For the header, we have used data-theme=’b’ and for the navigation bar, we have used class=’ui-body-b’,

jQuery Mobile: Button on the right hand side of the header

This entry is part 52 of 73 in the series jQuery Mobile

Many app designers like to put a button on the top of the page.

For example, we put an info button on the right hand side of the header bar.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js'></script>
    <title>Codecrawl</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header'>
        <h1>I'm a header</h1>
        <a href='#' data-icon='info' class='ui-btn-right'>Info</a>
        <div data-role='navbar'>
            <ul>
                <li><a href='#'>One</a></li>
                <li><a href='#'>Two</a></li>
                <li><a href='#'>Three</a></li>
            </ul>
        </div><!-- /navbar -->
    </div><!-- /header -->

    <div data-role='content'>
        <p>You can put your content here...</p>
    </div>

    <div data-role='footer'>
        <h1>My Footer</h1>
    </div>
</div>

</body>
</html>
Try The Code

The line needed for the info button is:

<a href='#' data-icon='info' class='ui-btn-right'>Info</a>

button_r