CSS
CSS, short for Cascading Style Sheets and it is the language we use to style an HTML document. It allows developers to style and format web pages by specifying how elements should appear, including colors, fonts, spacing & layout.CSS can be applied directly within HTML, embedded in <style> tags, or linked externally via .cssfiles, which promotes reusability and faster page loading.
How to Add CSS ?
When a browser reads a style sheet, it will format the HTML document according to the information in the style sheet. There are three ways of inserting a style sheet:
External CSS - it links to external file by using
.cssfile.Internal CSS - it may be used if one single HTML page has a unique style & it is defined within the
<style>element, inside the<head>section of an HTML page.Inline CSS - An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.
Comments
Comments are used to explain the CSS code, and may help when you edit the source code at a later date. Comments are also used to temporarily disable sections of CSS code within a stylesheet. Comments are ignored by browsers. A CSS comment is placed inside the HTML <style>element, and starts with /* and ends with */. For example,
l{
color: red; /* Set text color to red */
}
Padding
it is used to create a space inside the box, and it creates space across all sides of the box like top, bottom, left & right.
padding:20px;
Margin
it is used to create a space outside the box, and it creates space across outer sides of the box like top, bottom, left & right.
margin: auto;
margin-top:10px;
margin-bottom:10px;
margin-left:10px;
margin-right:10px;
Global selector
* it is global selector and it is used in start of every html & css codes to helps a size issues.
*{
padding:0;
margin:0;
box-sizing: border-box;
Text center
text-align: center;
it is used to align the texts in the center of the box.
Top comments (0)