jQuery Selectors: Universal selector *

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

We first look at the universal selector * where it selects all HTML elements.

The <h4>, <p> and <a>  were all selected using *.

<!DOCTYPE html>
<html>
<head>
    <script src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
    <script>
        $(function () {
            $('*').css('color','blue');
        });
    </script>
</head>
<body>
<h4>Ushuaia</h4>
<p>Southernmost city in the world.</p>
<a href='http://en.wikipedia.org/wiki/Ushuaia'>Visit us here.</a>
</body>
</html>

CSS3 Selectors: Universal selector *

This entry is part 4 of 40 in the series CSS3 Selectors

A universal selector * will select any html element.

In the example below, both the <h2> and <p> elements have been selected.

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Codecrawl.com</title>
    <style>
        * {
            color: blue;
        }
    </style>
</head>
<body>
<h2>Taylor Swift</h2>
<p> Swift moved to Nashville, Tennessee, at the age of 14 to pursue a career in country music.</p>
</body>
</html>