Removing an Object with CSS
One of the most popular tasks that re-occurs in web development is removing objects from a page. This object(s) may not be able to be removed easily through an HTML editor interface and that is where CSS comes in. Removing an object with CSS requires the element name that contains the object to be removed.
To discover what the element is controlled by, we can use Developer Tools in Chrome. To get there, navigate to the page you want to edit and right click on the page. Scroll to the bottom of the options menu and select “Inspect Element.” This will pop up a code screen at the bottom that will highlight the different parts of the page and show the corresponding code elements. Click and drag to highlight the object to be removed and then check the code below to see the name of the div id or div class that controls that object.
Once it is discovered, go to the style sheet for the site, or write the CSS inline.
DIV ID’s:
#element {
display: none;
}
-or-
DIV CLASSES’s:
.element {
display: none;
}
Replace the word “element” above with the ID or CLASS name we discovered earlier that was around the exiting object. Now save and check the page to see if the object is removed. If this doesn’t work, check the code to see if any errors have occurred in the typing.
If the object cannot be removed through above method, then it may be possible to write a DIV ID and reference it to the display:none; CSS. To do this it will be necessary to locate the file that the object to be removed is inside. Go to the object and write the following code around it:
<div id=”objectremove”>
–this is the object to be removed–
</div>
Then we will reference that element either in the external style sheet or in the same page using internal CSS. The internal CSS would look like such:
<style>
#objectremove {
display: none;
}
</style>
<div id=”objectremove”>
–this is the object to be removed–
</div>
Hope that helps remove any pesky parts of your site!
Have something to add to this tutorial? Share it in the comments.
Leave a Reply
Want to join the discussion?Feel free to contribute!