Question

More explanation, the better.In order to answer the following questions, you may wish to read...

In order to answer the following questions, you may wish to read about margin, padding and about border and border shortcut. 

1. Describe (in English) what the following CSS declarations do?

- padding: 5px 30px 20px 5px;

- margin: 0.25em 1em;

- border: thin solid blue;

2. Below, we have CSS declarations that assign a value made of 4 sizes to each of the two properties margin and padding. Can you rewrite these CSS declarations such that the two properties margin and padding are each assigned a value composed of fewer than 4 sizes?

- margin: 10px 12px 8px 12px?

- padding: 10px 12px 10px 12px?

3. Web browsers read CSS stylesheets from top to bottom and apply each CSS declaration as they read them. So if we create this CSS style rule:

some_selector {

padding: 25px;

padding-left: 80px;

}

what would the result be? Describe the result.

4. And if we create this CSS style rule:

some_selector {

padding-left: 80px;

padding: 25 px

}

would the result be the same as in Question 3?


1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

All html elements can be considered as boxes. The css box model represents the layout of the site. It consists of margins,borders,paddings and the actual content.

See in image

Margin (transparent). Border TOP 1 Padding - CONTENT LEFT RIGHT I BOTTOM

All these properties work in same order - top, right,bottom and left.

Margin

The css margin properties are used to create space around elements, outside of defined borders.

For specifying the margin for each side of an element :

margin-top, margin right, margin-bottom, margin-left

All the margin properties can have the following values:

  • length - specifies a padding in px, pt, cm, etc.
  • % - specifies a padding in % of the width of the containing element
  • inherit - specifies that the padding should be inherited from the parent element

Margin Shorthand property

You can specify all the margin properties in one property.

margin: 20px 40px 65px 60px;

here margin have four values

  • top margin is 20px
  • left margin is 40px
  • bottom margin is 65px
  • left margin is 60px

If the margin property have three values:

margin:20px 40px 70px;

  • top margin is 25px
  • right and left margins are 50px
  • bottom margin is 75px

If the margin property has two values:

margin:20px 40px;

  • top and bottom margins are 25px
  • right and left margin are 50px

If the margin property has one vlaue:

margin:20px;

  • All four margin are 25px

You can also set the margin to auto to horizontally center the element wits its container.

The inherit value take the value from parent elemet.

Note: Negative values are allow.



Css Padding

The css padding properties are used to generate space around an element's content, inside of any defined borders.

padding-top, padding-right, padding-bottom, padding-left

All the padding properties can have the following values:

  • length - specifies a padding in px, pt, cm, etc.
  • inherit - specifies that the padding should be inherited from the parent element
  • % - specifies a padding in % of the width of the containing element

Note: Negative values are not allowed.

Padding Shorthand property can specify same as margin shorthand property.

Css Border Properties

The css border properties allow you to specify the style, width and color of an element's border.

Border Width



The properties for the border can be set separately. The border-width property specifies the width of the border.

border-width:2px;

Border Color



The border color of the element can be defined using a color name, RGB, or Hex values.

border-color: red;

The border-style Property



The default value of border-style is none, which defines no border.
There are various styles supported for the border-style property:

  • dotted - Defines a dotted border
  • dashed - Defines a dashed border
  • solid - Defines a solid border
  • outset - Defines a 3D outset border. The effect depends on the border-color value
  • none - Defines no border
  • hidden - Defines a hidden border
  • double - Defines a double border
  • groove - Defines a 3D grooved border. The effect depends on the border-color value
  • ridge - Defines a 3D ridged border. The effect depends on the border-color value
  • inset - Defines a 3D inset border. The effect depends on the border-color value

CSS Border - Individual Sides

In CSS, there are also properties for specifying each of the borders (top, right, bottom, and left):

  • border-top-style: solid;
  • border-right-style: none;
  •   border-bottom-style: dotted;
  •   border-left-style: solid;

If the border-style property has four values:

border-style: dotted solid double dashed;

  • top border is dotted
  • right border is solid
  • bottom border is double
  • left border is dashed

If the border-style property has three values:

border-style: dotted solid double;

  • top border is dotted
  • right and left borders are solid
  • bottom border is double

If the border-style property has two values:

border-style: dotted solid;

  • top and bottom borders are dotted
  • right and left borders are solid

If the border-style property has one value:

border-style: dotted;

  • all four borders are dotted

The border property shown here also work same for border-width and border-color.

CSS Border - Shorthand Property

To shorten the code, it is also possible to specify all the individual border properties in one property.

  • border-width
  • border-style
  • border-color

Q1.

padding:5px 30px 20px 5px;

here padding genrate space around the element.

  • top padding is 5px
  • right padding is 30px
  • bottom padding is 20px
  • left padding is 5px

margin:0.25em 1em;

here margin properties create space around elements, outside of any defind borders.

here

  • top and bottom margin are 0.25em
  • right and left margin are 1em

border:thin solid blue;

this css border property make a solid thin blue color border around the element.

Q2.

marigin:11px 10px;

padding:11px 11px;

Q3.

some_selector{

padding:25px;

padding-left:80px

}

here padding top,right bottom be 25px and padding left be 80px becaus the browser accept the last value you set.

Q4.

some_selector{

padding-left:80px

padding:25px;

}

here result be the all padding 25px.Stats

The result is different from Q3.

Add a comment
Know the answer?
Add Answer to:
More explanation, the better.In order to answer the following questions, you may wish to read...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Does my css style sheet look okay? /* Author:       Your Name --> Natasha Strange /*...

    Does my css style sheet look okay? /* Author:       Your Name --> Natasha Strange /* Date:           Today's Date --> September 22, 2019 /* Description:   Lab Number --> Lab04 /*doctype css*/ @import url(fonts/chuckfive.css); @import url(fonts/merriweather.css); body    { background-color: rgb(199,201,191);        } div { border: 1px solid black;        padding: 100px 100px 100px 100px;        background-color: gray; } nav { text-align: center;    color: rgb( 7,20,138); } header, footer   { background-color: rgb(199,201,199);        color:...

  • As part of this assignment we are using the base Gallery HTML and writing JavaScript code...

    As part of this assignment we are using the base Gallery HTML and writing JavaScript code that will: 1) preload the images provided to us, 2) Create rollover functionality for each of the thumbnails in your image gallery 3) Use appropriate images found in the images folder. 4) Write developer comments to describe the variables being declared and explain the functions and logical blocks of JavaScript code pertaining to the gallery. I know it has to be an external JS...

  • Can you please assist me with this HTML? Below is what I have but it isn't...

    Can you please assist me with this HTML? Below is what I have but it isn't working. Filename: jpf_sudoku.css /* Table Styles */ table.spuzzle { border-collapse: collapse; margin-top: 0px; margin-bottom: 0px; margin-left: auto; margin-right: auto; width: 90%; } table.spuzzle td { border: 5px outset gray; width: 33.3%; } table.spuzzle th { font color: gray; padding-right: 10px; padding-bottom: 10px; } /* Inner Table Styles */ table.subTable { border-collapse: collapse; width: 100%; } table.subTable td { box-shadow: 0px 0px 15px inset; border:...

  • You will use your text editor to create a table and apply table styles. First, you...

    You will use your text editor to create a table and apply table styles. First, you insert a table element. Next, you add a table caption, table rows, table headers, and table data. Then, you create style rules to format the table. Work with the apply08.html file and the applystyles08.css file. You will also use professional web development practices to indent, space, comment, and validate your code. 3. In the apply08.html file, add a table element within the main element....

  • 2 Apply Your Knowledge Reinforce the skills and apply the concepts you learned in this chapter Styling a Webpage Instru...

    2 Apply Your Knowledge Reinforce the skills and apply the concepts you learned in this chapter Styling a Webpage Instructions: In this exercise, you will use your text editor to create external, embedded, and inline styles for the Durango Jewelry and Gem Shop home page. You will style the sections of the semantic wireframe header, nav, main, and tooter and a div element that surrounds all of the content to center the content on the page. You will also float...

  • How do I get my HTML and CSS to look similar to this mockup? HTML: <!DOCTYPE...

    How do I get my HTML and CSS to look similar to this mockup? HTML: <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>nitro site</title>     <link href="css/main.css" rel="stylesheet"/> </head> <body>     <header class="header">     <section class="navlist">         <img class="logo" src="assets/logobeans.png"/>         <h2 class="headertitle">nitro</h2>     <nav>         <ul>             <li><a href="index.html" target="_parent">About</a></li>             <li><a href="/html/menu.html" target="_blank">Menu</a></li>             <li><a href="/html/menu.html">Shop Now</a></li>         </ul>     </nav>     </section>     <section class="headerContainer">         <h1 class="heading">Nitro Coffee</h1>         <p class="productDesc">Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain Coffea species.</p>...

  • can you do this js and html question. ill give you the html and js and...

    can you do this js and html question. ill give you the html and js and css files just fix my error use if and else like what i did dont use switch just fix my erorr. <!DOCTYPE html> <!-- Webpage HTML document for Lab 4. Authors: Amirhossein Chinaei, Andriy Pavlovych For: EECS 1012, York University, Lassonde School of Engineering --> <html lang="En"> <head> <meta charset="UTF-8"> <!-- title for web page --> <title> EECS1012: Lab 4 - Computational Thinking </title>...

  • Create your own grid-based page using the sample HTML. Generate a Grid ( Experiment with Different...

    Create your own grid-based page using the sample HTML. Generate a Grid ( Experiment with Different Tools ) http://gridcalculator.dk/ Implement grid on the sample html file using pixels Convert to a percentage-based grid HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Out with the old...</title> <link rel="stylesheet" href="path-to-style.css"> <meta name="description" content="We are going to refine this document down to a good starting point for all html5 projects moving forward."> <meta name="author" content="ABC"> <link rel="shortcut icon" href="/favicon.ico" /> </head> <body> <div...

  • Help writing an online quiz that implements a simple quiz? Every time I click the button...

    Help writing an online quiz that implements a simple quiz? Every time I click the button to submit my answers the page is refreshed and no final grade is shown and I don't know why. Below is my code. <!DOCTYPE html> <html> <head> <h1>All images gotten from http://www.yogacards.com/yoga-pose-cards.html</h1> <style> body { background-color: black; font-family: Helvetica; } #main { width: 80%; max-width: 950px; border: 1px gray solid; margin: auto; padding: 10px; background-color: white; border-radius: 10px; } #header { margin-top: 0; border:...

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