$type=carousel$cols=3$cate=0$date=1

Using Class And Id

If an element has an id it will refer to only one element of that page whereas  if that  element has a class it can refer to several elem...

If an element has an id it will refer to only one element of that page whereas  if that  element has a class it can refer to several elements. According  to rules each element can  have only one ID and should  be used  only once.

Your code will not pass the validation if you use the same ID on more than one element.

I case of a class you can use the same on multiple elements.

If you want to use style over and over again on different types
of element in more than one places you need to use a class selector.

A styling that needs to be applied over and over to a different types of elements on a page you should use a class selector.
You can also use a span to apply a style to a specific word or more using a class selector.

A (.) dot refers to a class
example .class

A (#) hash refers to an id
example #id

Below is an example to show an explanation between classes and ids using some various style rules.

HTML
        <html>
        <body>
        <p class="sentence">This sentence has a class selector</p>

        <p>The underline <span class="underline sentence bold">word</span> in this paragraph
        is important.</p>

        <div id="content">
        <p class="red">This is RED color with a class selector.</p>
        <p class="green">This is GREEN color with a class selector.</p>
        <p class="orange">This is ORANGE color with a class selector.</p>

        </div>
        </body>
        </html>

CSS
        .sentence {
        font-size:30px;
        }

        .underline {
        text-decoration:underline;
        background-color:yellow;
        font-style:italic;
        }

        .bold {
        font-weight:bold;
        }

        #content p:hover  {
            color: gray;

        }

        #content {
        font-size:30px;
        cursor:pointer;
        margin:none;
        }

        .red {
        color:red;
        }

        .green {
        color:green;
        }

        .orange {
        color:orange;
        }



RESULT


This sentence has a class selector
The underline word in this paragraph is important.
This is RED color with a class selector.
This is GREEN color with a class selector.
This is ORANGE color with a class selector.


END...

COMMENTS

Name

css,17,html,7,php,2,python,1,tech,18,
ltr
item
iWriteLess Tech Blog: Using Class And Id
Using Class And Id
iWriteLess Tech Blog
http://www.iwriteless.com/2015/12/using-class-and-id.html
http://www.iwriteless.com/
http://www.iwriteless.com/
http://www.iwriteless.com/2015/12/using-class-and-id.html
true
2724151228810149585
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share. STEP 2: Click the link you shared to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy