JavaScript – Clear Inline Style of Paragraph

To clear Inline Style of a paragraph using JavaScript, get the reference to the paragraph element, and assign empty string value to the property.

Note: This solution clears only the inline style. Any global styles using style sheets shall be applied to the element.


<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
    <p id="myPara" style="color:red;width:200px;border:1px solid green">Clear Inline Style Paragraph in JavaScript</p>
    <button type="button" onclick="changeStyle()">Click Me</button>
    function changeStyle(){
        var element = document.getElementById("myPara"); = "";
Try Online


In this JavaScript Tutorial, we learned how to clear inline style of a paragraph using JavaScript.