How to Style Elements By Type with CSS

If you have the following HTML page:

  <title>My Page</title>
  <link rel="stylesheet" type="text/css" href="style.css"/>

and you want to apply a style to all <div> elements on a page, you can, as follows:

div {
    border: 3px solid lightgrey;
    font-size: 20px;
    font-weight: bold;
    font-family: Arial;
    margin-top: 20px;
    color: #76B9DE;

Notice we didn't have to use a # or a . selector to select by type.

The result:

the words Lemon Lime Soda in separate bordered divs on a web page


Leave a comment

What color are brown eyes? (spam prevention)
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.