Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the uses of CSS IDs and Classes in mark-up using HTML5 and CSS3?

Tags:

html

css

How to reduce the uses of CSS IDs and Classes in mark-up using HTML5 and CSS3?

Which HTML5 tags and CSS3 properties can reduce the need of classes and IDs

Currently I know

       <header>
        <nav>
        <section>
        <article>
        <aside>
        <footer>
    <time>
    <figure>
    <dialog>
    <mark>
<figcaption>
<hgroup>
like image 678
Jitendra Vyas Avatar asked May 19 '11 02:05

Jitendra Vyas


People also ask

How are classes and IDs used in HTML and CSS?

The difference between Class and ID selector The difference between an ID and a class is that an ID is only used to identify one single element in our HTML. IDs are only used when one element on the page should have a particular style applied to it. However, a class can be used to identify more than one HTML element.

Should I use IDs or classes in CSS?

You should use a class if you need to use the same selector more than once within a page or a site. While an ID is specific to a single element, classes can be assigned to multiple elements on a page or throughout the website. They are not unique.

What are the 3 ways CSS can be added to HTML?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.


1 Answers

The way these reference neighbors could be considered using less ids, and the html 5 tags with colons. This came from the Mix 11 videos.

CSS pop up menu:

.menu > li > ul {display: none;}
.menu > li:hover > ul { display:block;}

Dependent content:

.faq > div {display:none;}
.faq > div:target {display:block;}

Validation:

:valid, :invalid, :required, :optional, :in-range, :out-of-range, 
:read-only, :read-write

#signup input:focus:required:valid + .val .invalid {display:none;}
#signup input:focus:required:invalid + .val .valid {display:none;}

Animations:

.faq > div {display:none;}
.faq > div:target {display:block;position:relative;
       -webkit-animation:throb 1.5s infinite;}
like image 128
Zachary Scott Avatar answered Nov 03 '22 00:11

Zachary Scott