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");
Very good post i learned many thing about this topic.