Question

For CSS elements, when you should use class and when you should use id to form HTML component. TT T Arial 3 (12pt) TEE 5.02 P
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

You assign an id attribute to an HTML element when You want to stylize that element differently than other elements of the same type.

For ex.

  <p id="alert">Important! All classes are cancelled today.</p>

To add style to an element with an id, you preface the id with a # symbol in your CSS. For example, here's how we could make our alert paragraph appear in a big yellow box with a black border and big black text:

  p#alert {
    color: black;
    font-weight: bold;
    background: #FFFF66; /* yellow */
    border: 2px solid black;
    padding: 1em;
  }

Sometimes there might be a group of elements that you want to stylize in a certain way. For example, let's say you're creating an entertainment web page that includes several movie reviews, in addition to other content. The entire content of each review (a heading with the movie title, plus several paragraphs) is wrapped in a <div> in order to keep it all together in one box. The first paragraph of each review is a short summary describing the movie, then all remaining paragraphs contain the content of your critique of the movie. You may want to stylize the <div> elements that contain each review differently than other <div> elements on the page, so reviews all have a distinct look, but consistent with one another. You could accomplish this by assigning class="review" to each of these reviews. Also, you might want the summary paragraph to have a distinctive look, different from all other paragraphs. You could accomplish this by assigning class="summary" to each summary paragraph. Your code might look something like this:

  <div class="review">
    <h2>The Godfather</h2>
    <p class="summary">The Godfather (1972) is the greatest movie of all time,
      according to numerous surveys of movie critics and audiences alike.</p>
    <p>The Godfather is... (your review here)</p>
  </div>
  <div class="review">
    <h2>Avatar</h2>
    <p class="summary">Avatar (2009) is the highest grossing film of all time,
      earning approximately $2.8 billion.</p>
    <p>Avatar is... (your review here)</p>
  </div>

To add style to all elements that are part of a particular class, you preface the class name with a period (.) in your CSS. For example, here's how we could add a pale blue background and dark blue border to all movie reviews, and add italics to all summary paragraphs:

  div.review {
    background-color: #E6EBF5; /* pale blue */
    border: 1px solid #003399; /* dark blue */
  }
  p.summary {
        font-style: italic;
  }

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
For CSS elements, when you should use class and when you should use id to form...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in C++ Path: P Words:0 QUESTION 29 Write the code that allows you to input one...

    in C++ Path: P Words:0 QUESTION 29 Write the code that allows you to input one number and print whether it is even or odd. Include variable declarations. Your variable should be your first name. You will lose points for a different variable name. TTTT Paragraph • Arial • 3 (12pt) %0DQ TT, Of Mashups HTML CSS Path:p Words: 0 Click Save and Submit to save and submit. Click Save All Answers to all misters Sa

  • Question 13 10 points Save Answer Why does $100 in the future not have the same...

    Question 13 10 points Save Answer Why does $100 in the future not have the same value as $100 today? T TT T- E- Arial 3 (12pt) Path: p Words:0 Click Submit to complete this assessment. Question 13 of 13 « Save and Submit JUN W P W 14 Question 13 10 points Save Answer Why does $100 in the future not have the same value as $100 today? T TT T- E- Arial 3 (12pt) Path: p Words:0 Click...

  • COH COH А 1. Identify the reagents (diene and dienophile) you would use to prepare compound...

    COH COH А 1. Identify the reagents (diene and dienophile) you would use to prepare compound A. 1. Using your reagents from part I above, show the detailed, stepwise mechanism for each of the synthesis of compour Arial Y T TT TT Paragraph % LOQ 3 (12pt) Τ Τ.Ε. Ο Τ: HTML CSS e fi Mashups T Path: han

  • -VOUSL_1&course_jd=27805_1&con What are the five signs of metabolic syndrome? TTT Arial 3 (12pt) · TEE 5.0...

    -VOUSL_1&course_jd=27805_1&con What are the five signs of metabolic syndrome? TTT Arial 3 (12pt) · TEE 5.0 Path: P QUESTION 6 What are the four major types of diabetes? Describe the differences amon TT T Arial 3(12po TEE T uwentid=_53031_18course_jd=_27805_18cont QUESTION 7 What are the risk factors for hypertension? TTT Arial 3 (12pt) TEE Path: P 10p QUESTION 8 What is the difference between cancer initiation and cancer promotion? T T T Arial 3 (12pt) : T.E.E . and which Click...

  • plz help the inoculating loop After you use an inoculating loop to transfer bacteria from a...

    plz help the inoculating loop After you use an inoculating loop to transfer bacteria from a culture tube onto a slide, you should before putting it away For the toolbar, press ALT+F10 (PC) or ALT-FN-F10 (Mac). TTTT Paragraph Arial 3 (12pt) E - T %D0Q TT. Пнти се QIX I Path: P Words:0 QUESTION 3 In lab, bacterial cultures (Petri plates and tubes of culture broth) should be kept covered at all times. This is partly to protect us from...

  • Question 13 10 points Save Answer Why does $100 in the future not have the same...

    Question 13 10 points Save Answer Why does $100 in the future not have the same value as $100 today? T TT T- E- Arial 3 (12pt) Path: p Words:0 Click Submit to complete this assessment. Question 13 of 13 « Save and Submit JUN W P W 14

  • plz do 20th question as soon as possible by showing all formulas QUESTION 20 An radioactive...

    plz do 20th question as soon as possible by showing all formulas QUESTION 20 An radioactive material decays exponetially at a rate of 6.8% per week. How much material will be lest after 1 year, if the initial amount was 40,000 kg. Include the equation of the model. TT TT Paragraph Arial 3 (12pt) T %DOQ T' TE 'S "T ft Mashups T" HTML CSS - Path: P Words: 0 QUESTION 21 A bacterial culture grows exponentiall at a rate...

  • QUESTION 9 Prepare a 3.4 mg dosage from an ampule labeled 10 mg in 10 ml.....

    QUESTION 9 Prepare a 3.4 mg dosage from an ampule labeled 10 mg in 10 ml.. TTT Arial 3 (12pt) TEE 5.02 Path:p QUESTION 10 Prepare a dose of 0.1 g. Available strength is 250 mg in 5 mL. TT T Arial 3(1201) T.E. 2 Click Save and Submit to save and submit. Click Save All Answers to save all answers * 00

  • QUESTION 16 Explain the purpose and application of binary systems. T E T TT Arial 3...

    QUESTION 16 Explain the purpose and application of binary systems. T E T TT Arial 3 (12pt) Path: p Click Save and Submit to sae and submit. Click Save All Answers to save all answers. QUESTION 16 Explain the purpose and application of binary systems. T E T TT Arial 3 (12pt) Path: p Click Save and Submit to sae and submit. Click Save All Answers to save all answers.

  • QUESTION 8 An object weighs 8.4 N when it is in air and 4.6 N when...

    QUESTION 8 An object weighs 8.4 N when it is in air and 4.6 N when it is immersed in water of density 1000 kg/m3. What is the density of the object? Show the calculations using the Math Editor, and write the final answer with proper unit. Arial E- T- TTTT Paragraph %DOQO O fx Mashup T6 3 (12pt) T' T2 25 HTML CSS Path: P QUESTION 9 If the raceure reading of unurnitat tuho ie 12 mm Hantaenood of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT