Open In App

How to fix browser-specific styling issues in CSS ?

In this article, we will learn how to approach fixing browser-specific styling issues. You can approach the problem by inspecting the page and when you find a bug or an area that you want to change or modify the inspect tool will ease your work by finding the location of the element and the dimension of that element.

How would you approach fixing browser-specific styling issues? 



Step 1: Your first step is to run your code into the browser and debug the code using Inspect Element Tool. Below are the shortcuts mentioned according to the device:

Shortcuts for Mac:



Shortcuts for Windows/Linux:

 

Step 2: In the next step after finding the issue and the offending browser, then use a separate style sheet that only loads when that specific browser is being used.

Step 3: In the last step you can update the browser once. If you find any bugs after updating then you may read the document to see where your style is going wrong or you can also use the bootstrap libraries that already handle these styling issues for you.

Why CSS is not showing the output that we want to see?

This is because your current CSS properties are overriding the old CSS properties and in CSS terminology this concept is known as Specificity and we can also say that the new CSS is crossed out.

Approach:

Example1: In the below code, we will see how you can find the bug using inspect tool.




<!DOCTYPE html>
<html>
  
<head>
    <title>How to approach fixing 
      browser-specific styling issues?</title>
</head>
  
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h3>A computer science portal for geeks</h3>
        <container>
            <div style="background-color:green; 
                        height:200px; width:400px">
                <section style="font-size:40px; color-white; 
                                padding-top:50px;">GeeksforGeeks</section>
            </div><br>
            <div style="background-color:green; 
                        height:100px; width:200px">
                <section style="font-size:20px; color-white; 
                                padding-top:30px;">GeeksforGeeks</section>
            </div>
        </container>
  
    </center>
</body>
  
</html>

Output:

 

Explanation: When you hover over the element then it will show you the exact location and dimensions of that element.

Example2: In the below code, we will see how you can find the bug using inspect tool.




<!DOCTYPE html>
<html>
  
<head>
    <title>How to approach fixing 
      browser-specific styling issues?</title>
</head>
  
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h3>A computer science portal for geeks</h3>
    </center>
</body>
  
</html>

Output:

 

What are the issues in HTML?


Article Tags :