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..

    Slideshow with specific Text on each Image

    How to make sticky navigation change colour when scrolling past a certain div?

    How do I apply CSS styles to Raphael.js objects using jQuery?

    How to make DIVs flow to the left in a x-scrollable pane with CSS?

    How do I use CSS to to vertically center align an image in a div?

    How to use z-index to make an element overlap another element in CSS

    How to programmatically ungroup CSS selectors?

    How to create a Page Header (an Image) for print using css

    How to move a CSS class below another? [closed]

    How to apply gradient to the border of a div?

    How to flip multiple divs using CSS?

    How do I set frame alignment?

    django render_to_response how to send special characters

    how to change height of ellipse in radial gradient in css for background property

    How to make a GWT-like CaptionPanel manually

    How to segregate these divs with 'position:absolute' into different groups?

    How to prevent mobile browser micro-shrinking HTML block level elements?

    How to take an element over to given padding with CSS

    How do i apply scroll for long horizontal background image?

    How to convert a piece of CSS code to LESS css

    How To Center A CSS Drop Down Menu [closed]

    How do I get content to overflow into another div if there is room, using css?

    Content shows up when clicked on the link

    CSS Image size, how to fill, not stretch?

    CSS image rollover map and jQuery : how to use a second li list?

    How can I disable the “Up” arrow via CSS

    How to keep the underline effect in this demo stay using CSS?

    Show div only on Homepage using only JS & CSS

    How to override a part of the style in the site.master page?

    how to I make my responsive website look normal on galaxy s4 (media query)