Removing an Object with CSS

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.
Chrome Developer Tools Logo
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.

Jophiel Silvestrone

Written by: Jophiel Silvestrone

Jophiel Silvestrone has written 163 posts in the Tech Blog.

Jophiel grew up on a ranch in Paradise Valley, Montana near Chico Hot Springs. Working on the ranch instilled work ethic and self motivation. Filled with this drive, Jophiel started mowing the local school's yards twice a month throughout the summers, at the age of 12. He moved to Billings in 2004, where he has been deeply involved in the local business community ever since. A serial entrepreneur, Jophiel has ran multiple businesses in our local community. He now runs a web development company SkyPoint Studios. One of his favorite jobs though, is fathering his 11-year old son Jaoquin. "JJ" also loves technology.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.