CSS: how to add a style to everything, unless it is defined


Tags: css

Problem :

If I add a style like:

* {
  font-size: 14px;
}

and later I define for an element:

#myElement {
  font-size: 18px;
}

The fist one will override the second one.

Is there a way to define the first one, such as the second one will override it, and the 14px size will be applied to all the elements that don't define a size?

(I would like alternatives to the use of classes)



Solution :

The element #myElement will override the first rule as it is more specific. If #myElement has children then the children will match the global selector. Try setting the rule on body.


    CSS Howto..

    How to shrink wrap floating content?

    How to Overcome Bootstrap's Default Styling? Element targeting issues?

    How to set animation in css?

    How to reset default button style in Firefox 4 +

    how to transform in both X & Y direction with CSS Only [duplicate]

    How to align items in second (and further) column, so that the changing value (increasing characters) do not push

    How to float 3 divs with margin left & right 0px?

    how to change the div background image in mouse over [duplicate]

    How can I check if CSS calc() is available using JavaScript?

    How to Make Text Stay Inside Div?

    custom radio button show value inside

    Tab menu in CSS - how to set an active tab

    How do I replicate this website in terms of responsiveness using only css?

    How i can get the td data getting from css to attach to my current row ,and use for my logic

    How to emulate Google greyed-out suggested text in input element?

    How can I remove a bootstrap buttons hover effect?

    How to Center Text in a JavaScript Function?

    How to set the CSS class name dynamically in LessCSS?

    How to search a particular text within an HTML Text and highlight the search string with a color

    How to link css files to work correctly with wamp server?

    How to target the first-child of an optgroup with css or jquery

    how to horizontally center a div of 10000px (wider than full screen) in CSS?

    How to tune CSS with Isotope to display top border?

    JQuery with IE reading inherted css property, how to prevent?

    How can I display an image as a menu item once the user has scrolled down the page 150px?

    How to exclude particular class name in CSS selector?

    How to override CSS :hover?

    How can I use a CSS3 transform on an element without stretching the text inside it?

    How to adjust font awesome down arrow via css

    How Do I Add Colgroup Tag to ASP:Datagrid Control?