Skip to content

Latest commit

 

History

38 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Lab 5

Content Style

The Content Covered:

  1. Style Element
  2. Font Family
  3. Font Size
  4. Font Weight
  5. Font-Style
  6. Font-Variant
  7. Font
  8. Text-Align
  9. Text-Decoration
  10. Text-Transform
  11. Text-Indent
  12. Margin-Top
  13. Margin-Right
  14. Margin-Bottom
  15. Margin-Left
  16. Max-Width
  17. Padding
  18. Margin
  19. Display: Flex
  20. Border-Bottom
  21. Border-Top
  22. Border-Radius
  23. Nav Element
  24. Nav A
  25. Nav Li
  26. List-Style-Type
  27. Nav Ul
  28. Background-Color
  29. Display
  30. Pseudo-Classes
  31. Nav a:link
  32. Nav a:visited
  33. Nav a:hover
  34. Nav a:active
  35. The Box Model

CSS Cheat Sheet

Syntax Description Example
<style></style>
A tag used to define CSS styles within an HTML document.
<style>
    body {
        background-color: lightgray;
    }
</style>
font-family Specifies the font of the text.

    p { 
        font-family: Arial, sans-serif; 
    }
font-size Defines the size of the font.

    h1 { 
        font-size: 24px; 
    }
font-weight Determines the thickness of the font.

    h1 { 
        font-weight: bold; 
    }
font-style Defines the style of the font (normal, italic, oblique).

    h1 { 
        font-style: italic; 
    }
font-variant Controls text appearance, such as small caps.

    h1 { 
        font-variant: small-caps; 
    }
font Shorthand for setting font-related properties.

    h1 { 
        font: italic bold 16px Arial, sans-serif; 
    }
text-align Aligns text to left, right, center, or justify.

    h1 { 
        text-align: center; 
    }
text-decoration Controls text underline, overline, and line-through.

    h1 { 
        text-decoration: none; 
    }
text-transform Changes the capitalization of text.

    h1 { 
        text-transform: uppercase; 
    }
text-indent Indents the first line of a paragraph.

    p { 
        text-indent: 20px; 
    }
margin-top Sets the top margin of an element.

    div { 
        margin-top: 10px; 
    }
margin-right Sets the right margin of an element.

    div { 
        margin-right: 10px; 
    }
margin-bottom Sets the bottom margin of an element.

    div { 
        margin-bottom: 10px; 
    }
margin-left Sets the left margin of an element.

    div { 
        margin-left: 10px; 
    }
max-width Sets the maximum width an element can be.

    div { 
        max-width: 600px; 
    }
padding Sets the space between an element’s content and border.

    div { 
        padding: 10px; 
    }
margin Shorthand property for setting margins.

    div { 
        margin: 10px 20px; 
    }
display: flex Defines a flex container.

    div { 
        display: flex; 
    }
border-bottom Sets the bottom border of an element.

    h1 { 
        border-bottom: 2px solid black; 
    }
border-top Sets the top border of an element.

    h1 { 
        border-top: 2px solid black; 
    }
border-radius Rounds the corners of an element.

    div { 
        border-radius: 10px; 
    }
background-color Sets the background color of an element.

    body { 
        background-color: lightblue; 
    }
display Determines how an element is displayed.

    div { 
        display: inline-block; 
    }
list-style-type Defines the appearance of list bullets or numbers.

    ul { 
        list-style-type: square; 
    }
pseudo-classes Used to define a special state of an element.

    a:hover { 
        color: red; 
    }
nav a:link Styles unvisited links in a navigation bar.

    nav a:link { 
        color: blue; 
    }
nav a:visited Styles visited links in a navigation bar.

    nav a:visited { 
        color: purple; 
    }
nav a:hover Changes the style when the mouse hovers over a link.

    nav a:hover { 
        color: red; 
    }
nav a:active Styles the link when it is clicked.

    nav a:active { 
        color: green; 
    }

The Box Model

An image of the box model

Example of CSS in jsfiddle

Fiddle: https://jsfiddle.net/15mky8hr/

Completed Fiddle: https://jsfiddle.net/joseortiz/dft983h2/

The Original Code:

<!-- Link to CSS Examples COMPLETED version:
https://jsfiddle.net/joseortiz/dft983h2/
-->

<!doctype html>
<html>
    <head>
        <title>Selectors Example</title>    
    </head>

    <body>
        <section>
            <article>
                This is the first article.
            </article>
            <article>
                This is the second article.
                <ul>
                    <li>Item 1</li>
                    <li>Item 2</li>
                </ul>
            </article>
            </section>

        <section>
            <article>
                This is the third article.
            </article>
            <article>
                This is the fourth article.
            </article>
        </section>

  </body>
</html>

The Modified HTML Code:

<html>

    <head>
        <title>Selectors Example</title>
    </head>

    <body>
        <section>
            <article class="box" id="main_box">
                This is the first article.
            </article>
            <article class="box">
                This is the second article.
                <ul>
                    <li>Item 1</li>
                    <li>Item 2</li>
                </ul>
            </article>
        </section>


        <section>
            <article>
                This is the third article.
            </article>
            <article>
                This is the fourth article.
            </article>
        </section>
  </body>
</html>

The CSS Code:

/* Type selector */
article {
    color: blue;
    margin: 10px;
}

/* Class selector */
.box {
    border: 1px solid black;
    padding: 10px;
}

/* ID selector */
#main_box {
    background-color: red;
}

/* Using combinators:
   Use a space to specify a descendant selector 
*/
.box li {
    color: purple;
}

The Result

The result of the HTML and CSS Code


Example of CSS in jsfiddle (My Version)

The Original Code:

<!-- Link to CSS Examples COMPLETED version:
https://jsfiddle.net/joseortiz/dft983h2/
-->

<!doctype html>
<html>
    <head>
        <title>Selectors Example</title>    
    </head>

    <body>
        <section>
            <article>
                This is the first article.
            </article>
            <article>
                This is the second article.
                <ul>
                    <li>Item 1</li>
                    <li>Item 2</li>
                </ul>
            </article>
            </section>

        <section>
            <article>
                This is the third article.
            </article>
            <article>
                This is the fourth article.
            </article>
        </section>

  </body>
</html>

The Modified HTML Code (MY VERSION):

<!-- Link to CSS Examples COMPLETED version:
https://jsfiddle.net/joseortiz/dft983h2/
-->

<!doctype html>
<html>

    <head>
        <title>Selectors Example</title>
    </head>

    <body>
        <section>
            <article id="redbox">
                This is the <em>first</em> article.
            </article>
            <article class="box">
                This is the second article.
                <ul>
                    <li>Item 1</li>
                    <li>Item 2</li>
                </ul>
            </article>
        </section>

        <section>
            <article class="box">
                This is the third article.
            </article>
            <article>
                This is the fourth article.
            </article>
        </section>

    </body>
</html>

The CSS Code (MY VERSION):

/* CSS Rule */
/* Selector */
/* Type Selector */
article {
    color: blue; /* Declaration */
    /*
    border-width: 1px;
    border-style: solid; 
    border-color: black; 
    */
    /* border: 1px solid black */
}

body {
    background: lavenderblush;
}

li {
    color: green;
}

/*
ul {
    color: red;
}
*/

/* Class Selector */
.box {
    border: 3px double black;
    padding: 10px;
    margin: 10px;
}

/* ID Selector */
#redbox {
    background-color: lightblue;
}

/* Combinator Selector  */
.box li {
    color: orange;
}

The Result

alt text

About

This repository is based on Lab Tutorial #5 on Content Styling.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages