HTML Element Style How to - Turn h1 as inline element and add underline








Question

We would like to know how to turn h1 as inline element and add underline.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
h1 {<!-- w w  w.  jav  a  2s  .c o  m-->
  border-bottom: 3px solid red;
  display: inline;
}
</style>
</head>
<body>
  <div>
    <h1>Hello, world</h1>
  </div>
  <p>Lorem ipsum</p>
</body>
</html>

The code above is rendered as follows: