ATTRIBUTES IN CSS(BASIC)

0


 ATTRIBUTES IN CSS(BASIC)



GAIN AND SHINE


    CSS (Cascading Style Sheets) is a style sheet language used for describing the presentation of a document written in HTML or XML. With CSS, web developers can style and format the layout, typography, colors, and other visual elements of a webpage. In this blog, we will explore some of the basic attributes in CSS and how they can be used to style webpages.


Color

    The color attribute is used to set the color of text or background in a webpage. It can be specified using a color name, a hexadecimal value, or an RGB value.

Here's an example:

h1 {

      color: red;

}


This will set the color of all <h1> headings to red.


Font

    The font attribute is used to set the font family, size, weight, and style of text in a webpage. 

Here's an example:

body {

     font-family: Arial, sans-serif;

     font-size: 16px;

     font-weight: normal;

     font-style: italic;

}


    This will set the font family to Arial (or a sans-serif font if Arial is not available), the font size to 16 pixels, the font weight to normal, and the font style to italic for all text in the <body> element.


Margin and Padding

    The margin attribute is used to set the space outside an element, while the padding attribute is used to set the space inside an element.

Here's an example:


div {

     margin20px;

     padding10px;

}


This will set a 20-pixel margin and a 10-pixel padding for all <div> elements in a webpage.


Border

    The border attribute is used to set a border around an element. It can be specified using the border-width, border-style, and border-color attributes.

Here's an example:


img {

     border1px solid black;

}


This will set a 1-pixel solid black border around all <img> elements in a webpage.


Background

    The background attribute is used to set the background color or image of an element. 

Here's an example:


body {

     background-colorlightgray;

     background-imageurl("background.jpg");

     background-repeatno-repeat;

     background-positioncenter;

}


    This will set the background color to light gray and the background image to "background.jpg" for the <body> element. The background image will not repeat and will be centered.


Conclusion

    CSS offers a wide range of attributes that can be used to style and format webpages. By using the right combination of attributes, web developers can create beautiful and functional webpages that engage users and deliver a great user experience. By mastering the basic attributes in CSS, developers can build a strong foundation for creating more complex and dynamic webpages in the future.


Post a Comment

0Comments

Share Your Feedback Here !!

Post a Comment (0)