Skip to main content

CSS Basics

Lesson 1: Introduction Of css

CSS (Cascading Style Sheets) is a language used for describing the presentation of a document written in HTML or XML. It controls the layout, appearance, and style of web pages. In this tutorial, we'll cover the basics of CSS and how to use it to style your web pages.

Getting Started

To use CSS, you'll need a basic understanding of HTML. HTML defines the structure and content of your web page, while CSS is used to style and format that content.

To Learn HTMl Basics Do Click Here


Setting up your HTML file

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>ABCSA CSS Tutorial</title>

    </head>

<body>

    <h1>Welcome to ABCSA CSS Tutorial!</h1>

    <p>This is a paragraph.</p>

</body>

</html>

Test the Above Code in ABCSA HTML Testing Editor Here

Lesson 2: Creating a CSS file

Create a new file named `styles.css` in the same directory as your HTML file.

What is the Syntax of making CSS?

selector {

    property: value;

}

Here is the description of above syntax code:

- **Selector:** Selects the HTML element you want to style.

- **Property:** The aspect of the selected element you want to change.

- **Value:** The value you want to assign to the property.


Basic Styling

Let's start with some basic styling examples:

/* Let's change the style of h1 tag */

h1 {

    color: blue;

    font-size: 24px;

}

/* Let's change the style of h3 tag */

h3 {

    color: yellow;

    font-size: 30px;

}

/* Targeting elements by class */

.myclass {

    background-color: yellow;

    padding: 10px;

}


/* Targeting elements by ID */

#my-id {

    border: 1px solid black;

}

Applying Styles

To apply these styles, save the CSS file and refresh your HTML page in the browser. You should see the changes reflected.

Lesson 3: What is CSS Box Model?

The term "box model" is used about design and layout of a web page.

In this we design a box to put every html element. 

There are different parts of box model :

  • Content - The content of the box, where text and images appear
  • Padding - Clears an area around the content. The padding is transparent
  • Border - A border that goes around the padding and content
  • Margin - Clears an area outside the border. The margin is transparent

let's understand this with example:

<!DOCTYPE html>

<html>

<head>

<style>

div {

  background-color: lightgrey;

  width: 300px;

  border: 20px solid blue;

  padding: 50px;

  margin: 20px;

}

</style>

</head>

<body>

<h2>Demonstrating the Box Model</h2>

<p>The CSS box model is essentially a box that wraps around every HTML element. It consists of: borders, padding, margins, and the actual content.</p>

<div>This text is the content of the box. We have added a 50px padding, 20px margin and a 15px green border. </div>

</body>

</html>

Check The above code in ABCSA HTML Editor Now

Lesson 4: Various example of CSS

Now let's check Various example of CSS practically i below Code:

examples of Different CSS style:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>CSS Styles Test</title>

    <style>

        /* Color and Text Styles */

        h1 {

            color: red;

        }


        p {

            font-size: 16px;

            font-family: Arial, sans-serif;

        }


        .bold-text {

            font-weight: bold;

        }


        /* Background and Border Styles */

        body {

            background-color: #f0f0f0;

        }


        .bg-image {

            background-image: url('background.jpg');

            background-size: cover;

        }


        .bordered-box {

            border: 2px solid black;

            border-radius: 5px;

        }


        /* Box Model and Layout */

        .sized-box {

            width: 200px;

            height: 150px;

        }


        .padded-box {

            padding: 20px;

        }


        .margined-box {

            margin: 10px;

        }


        /* Positioning and Display */

        .inline-block {

            display: inline-block;

        }


        .positioned-box {

            position: relative;

            top: 50px;

            left: 20px;

        }


        /* Animations and Transitions */

        @keyframes slidein {

            from {

                margin-left: 100%;

            }

            to {

                margin-left: 0%;

            }

        }


        .animated-box {

            animation: slidein 3s ease-in-out;

        }


        .transition-box {

            transition: background-color 0.3s ease-in-out;

        }


        .transition-box:hover {

            background-color: lightblue;

        }

    </style>

</head>

<body>


    <!-- Color and Text Styles -->

    <h1>Hello, CSS!</h1>

    <p>This is a paragraph.</p>

    <p class="bold-text">This paragraph is bold.</p>


    <!-- Background and Border Styles -->

    <div class="bg-image sized-box padded-box margined-box bordered-box">

        <p>This is a div with background image, border, padding, and margin.</p>

    </div>


    <!-- Positioning and Display -->

    <div class="positioned-box">

        <p>This div is relatively positioned.</p>

    </div>


    <span class="inline-block">This is an inline-block element.</span>


    <!-- Animations and Transitions -->

    <div class="animated-box transition-box">

        <p>This div has an animation and transition effect.</p>

    </div>


</body>

</html>

Test the Above Code in ABCSA Html Editor

Replace `'background.jpg'` with the actual path to your background image file. This HTML file demonstrates various CSS styles and effects applied to different HTML elements.

Lesson 5: Conclusion

This tutorial covers the basics of CSS, including syntax, selectors, properties, and the box model. Experiment with different styles and properties to see how they affect your web page. CSS is a powerful tool for controlling the look and feel of your website, so keep practicing and exploring to master it!

Lesson 6: Exercises For You

  1.  Make html code to change the background of paragraph with yellow color and font color to red.
  2. Write a code to animate the text "Best Online Course by ABCSA Online".
  3. Make a box model of your choice, choose different color of border, text and background as per your choice and test it in html editor to check your work. 
  4. Make css to change the color and text size of different headings - h1, h2, h3, h4, h5, h6.
  5. What is the meaning of CSS.

Lesson 7: Want Certification From ABCSA

Do contact ABCSA For Details.You Can also join our advance courses from our Centers in different cities.
End of Lessons

Comments

Popular posts from this blog

Page Maker Tutorial

Adobe PageMaker 7.0 learn page maker Chapter 1 - Basic Information - PageMaker  Basic Information: Adobe PageMaker is powerful and versatile page layout software. Professionals use PageMaker for its exceptional typographic controls, exacting page design capabilities, including layers, frames, and multiple master pages, and numerous customizing options.  PageMaker’s extensive importing and linking capabilities let you incorporate text, graphics, spreadsheets, charts, and movie frames from most popular programs. It also incorporates menu plug-ins that extend the program’s features and capabilities. It also supports advanced color printing technologies, including high-fidelity inks, color management support, automatic trapping, built-in imposition tools, and complete separation capabilities for text and graphics. Let us first understand the PageMaker Window with its various components. Fig 1 shows the important areas of the PageMaker window: To check figures do

Kaise Khole Computer Center Bharat Mai

कैसे खोले कंप्यूटर सेन्टर, how to open computer center, franchise opportunity to run computer center. kaise khole computer center bharat me Kaise Khole Computer Center Bharat Mai क्या आप कंप्यूटर सेन्टर चला रहे हैं क्या आप ISO सर्टिफाइड संस्था से जुड़ना चाहते हैं. क्या आप कंप्यूटर के क्षेत्र में अपना नाम करना चाहते हैं. क्या आप बहुत ही कम लागत में अपना स्वयं का कंप्यूटर शिक्षण का कार्य करना चाहते हैं. अगर इन सवालों का जवाब हाँ है तो आप अपने सपने को आज ही साकार कर सकते है “अखिल भारतीय कंप्यूटर शिक्षा अभियान ” से जुड़कर. अखिल भारतीय कंप्यूटर शिक्षा अभियान राष्ट्रिय स्तर पर संचालित संस्था है जिसकी फ्रेंचाइसी लेके आप सफलता पूर्वक अपना कंप्यूटर सेन्टर चला सकते हैं.  आप भारत में कहीं भी कंप्यूटर सेन्टर खोल सकते हैं ABCSA की फ्रैंचाइज़ी लेके. आप किसी गाँव में कंप्यूटर सेन्टर खोल सकते हैं. आप किसी तहसील में कंप्यूटर सेन्टर खोल सकते हैं.  आप किसी शहर में कंप्यूटर सेन्टर संचालित कर सकते हैं.  बनिए भागीदार डिजिटल इंडिया मिशन में आज ही फ्रैंचाइज़ी लेके. ABCSA से जुड़कर आप ऑ

Career In Information Technology

Millions of vacancy comes out every year in Information technology sector. It is the fastest growing industry where scope will never end because of digitisation. A computer literate person is not only able to get job in nation but there is a great scope in international level. So there is a good chance of making career in this field. best career options in IT And if any one is entrepreneur then no doubt he or she can earn unlimited as per the calibre. Any student who have done course from Akhil Bhartiya Computer Shiksha Abhiyan Can Make Career In following ways: Student can open his or her own computer education center/computer training center of hardware and software. Student can become web designer. Student can become a network engineer. He or she can become faculty/teacher in any institute. Person can get job as a computer operator. Student can start career as a hardware professional. Person can become a programmer or software developer. Student can work as