How to Protect an HTML element from it's respective assigned CSS


Tags: html,css

Problem :

Well I wish to know how one can avoid a specific html element from getting styled by the default assigned CSS to it. Let me explain with an example:

Suppose I have an image element with it's respective default CSS assigned to it (img{}) but if I want a particular image element like logo or social icons from getting the default CSS styling then what should I do?

I know of ID's being used to target specific elements in CSS but I wish to know if their is any other way of doing this using some special markup or CSS or use of the wrapped elements like div to overcome default values. Many Thanks in Advance! :)



Solution :

There is no way to prevent CSS rules with a selector that matches an element from applying to that element.

The best you can do is write more specific rules to override them with different values. You could, in browsers that support it, use the initial keyword.


    CSS Howto..

    CSS: how to stop text from taking up more than 1 line?

    How to render a template containing CSS with }} sequence inside using Twig

    How do I add inline css to dropdown in Yii?

    How to make diagonal div

    How to make div's width fit content not window

    Using CSS to create custom borders with just the corners showing

    How can I prevent overflow from a fieldset?

    How to insulate HTML widget from external CSS

    How to set alternate row color for a given attached diagram

    show/hide css menu item depending user role using asp.net

    how can I reload a “CSS background-image” each time I hover on it?

    Looping through my table, how do I know if the checkbox is checked?

    How to place two divs next to each other -HTML/CSS

    How can I make the header's border/other content not overlap the img on the left?

    jQuery - How to make images overlap when fading in and out?

    How to check if CSS is on an element? [closed]

    How to create a 3 section's in a row inside the colophon footer (wordpress)

    Percentages in CSS: How are they calculated internally?

    How to style a single QToolButton using qss/css

    How to add part of css property value through scope in ng-style in angular

    How to hide text present inside search box?

    How to create a nested vertical menu with horizontally sub-menus using css

    How do I stretch a div to be the height of the document body, not the viewport? (included code)

    How to style nested element that is styled by its parent already

    How can I convert to a CSS Drop down menu

    css: show all floating text (variable font size) on the baseline

    How to set CSS hover on input

    how to design a search panel like in mashable with css only

    How to reduce width of div using JQuery, CSS so that the left section is reduced and not the right?

    How to remove the bottom border of a box with CSS