What is the correct CSS syntax for making all the <p> elements bold?

There are multiple ways we can change <p> elements bold. For example by using inline CSS like  <p style="font-weight:bold">. But if we want to make all <p> element in a webpage bold then we can use the below CSS code-

p{
  font-weight: bold;
}

The above CSS code will make all <p> elements bold. So we don’t have to write the same inline CSS code multiple times.

CONTENTS

How to change all <p> element bold at runtime by using jquery or javascript?

The above CSS code will change all <p> elements to bold. But what if we need to change it at runtime? So we can easily change it either by jQuery or plain JavaScript.

By using jQuery:-

$("p").css("font-weight", "bold");

By using JavaScript:-

document.querySelectorAll('p').forEach(e => e.style.fontWeight="bold"); 

About Ashis Biswas

A web developer who has a love for creativity and enjoys experimenting with the various techniques in both web designing and web development. If you would like to be kept up to date with his post, you can follow him.

1 thought on “What is the correct CSS syntax for making all the <p> elements bold?”

Leave a Comment