SlideShare uma empresa Scribd logo
1 de 8
CSS Basics-1
                                                                   Mozahidur Rahman ‘Rousnay’
                                                                          portfolio.rousnay.com
                                                                         facebook.com/rousnay
                                                                           admin@rousnay.com
                                                                                   +01912671539

Introduction to CSS:
        A CSS (cascading style sheet) file allows you to separate your web sites HTML content
from its style. As always you use your HTML file to arrange the content, but all of the
presentation (fonts, colors, background, borders, text formatting, link effects & so on...) are
accomplished within a CSS. At this point you have some choices of how to use the CSS, either
internally or externally. All the various methods of stylesheet are used in the following order:

       1. Internal Style Sheet (inside the <head> tag)
       2. External Style Sheet
       3. Inline Style (inside HTML element)

Internal Style sheet:
        First we will explore the internal method. This way you are simply placing the CSS code
within the <head></head> tags of each HTML file you want to style with the CSS. The format
for this is shown in the example below.

<html>

       <head >
             <title> </title>

               <style type= "text/css" >

               ……….CSS Content Goes Here……..

             </style >
       </head>

       <body>
       …….your web site content goes to here……
       </body>

</html>

With this method each HTML file contains the CSS code needed to style the page. Meaning that
any changes you want to make to one page will have to be made to all. This method can be good
if you need to style only one page, or if you want different pages to have varying styles.

External Stylesheet:
        Next we will explore the external method. An external CSS file can be created with any
text or HTML editor such as "Notepad" or "Dreamweaver". A CSS file contains no HTML, only
CSS. You simply save it with the .css file extension. You can link to the file externally by
placing one of the following links in the head section of every HTML file you want to style
with the CSS file.

<link rel= "stylesheet" type ="text/css" href ="http://www.rousnay.com/stylesheet.css"/>

Either of these methods are achieved by placing one or the other in the
head section as shown in example below.

       <html>

                 <head >
                       <title> </title>

            <link rel= "stylesheet” type ="text/css"
       href="http://www.rousnay.com/stylesheet.css"/>

                 </head>

                 <body>
                 …….your web site content goes to here……
                 </body>

       </html>

Inline Styles:
       I have not mentioned them until now because in a way they defeat the purpose of using
CSS in the first place. Inline styles are defined right in the HTML file alongside the element you
want to style. See example below.

       <p style=" color: #ff0000; ">
               Some red text
       </p >

The final result is:
                Some red text


CSS Syntax:
       The syntax for CSS is different than that of HTML markup. Though it is not too
confusing, once you take a look at it. It consists of only 3 parts. In a typical CSS statement you
have the following:

  SELECTOR {PROPERTY: VALUE }

“PROPERTY" is the CSS element you wish to manipulate and "VALUE" represents the value of
the specified property. The “SELECTOR” name creates a direct relationship with the HTML tag
you want to edit. If you wanted to change the way a paragraph tag behaved, the CSS code would
look like:

  p { PROPERTY: VALUE }
Example:

        <html>
              <head>
                    <style type="text/css">
                    p {color: red;}
                    </style>
              </head>

              <body>
                    <p>Example of CSS Selector! </p>
                    <p>This paragraph is styled with CSS.</p>
              </body>
        </html>

The final result is:
                        Example of CSS Selector!

                        This paragraph is styled with CSS.


Each selector can have multiple properties, and each property within that selector can have
independent values. The property and value are separated with a colon and contained within
curly brackets. Multiple properties are separated by a semi colon. Multiple values within a
property are separated by commas, and if an individual value contains more than one word you
surround it with quotation marks. As shown below.

        body {
                 background: # eeeeee;
                 font- family: "Trebuchet MS", Verdana , Arial , serif;
        }

As you can see in the above code I have separated the color from the Font-family with a semi-
colon, separated the various fonts with commas and contained the "Trebuchet MS" within
quotations marks. The final result sets the body color to light grey, and sets the font to ones that
most users will have installed on their computer.

Combining Selectors:
        You can combine elements within one selector in the following fashion.

        h1, h 2, h3 , h4, h5, h6 {
                color : # 009900;
                font- family: Georgia , sans-serif;
        }

As you can see in the above code, I have grouped all the header elements into one selector. Each
one is separated by a comma. The final result of the above code sets all headers to green and to
the specified font. If the user does not have the first font I declared it will go to another sans-
serif font the user has installed on their computer.
CSS Comments:
       You can add comments that will be ignored by browsers in the following manner.

       /* this is a comment * /

You will note that it begins with a / (forward slash) and then an * (asterisks) then the comment,
then the closing tag which is just backward from the opening tag * (asterisks) then the /
(forward slash).

CSS Classes:
        The class selector allows you to style items within the same HTML element differently.
Similar to what I mentioned in the introduction about inline styles. Except with classes the style
can be overwritten by changing out stylesheets. You can use the same class selector again and
again within an HTML file. To put it more simply, this sentence you are reading is defined in my
CSS file with the following.

       p{
               font- size: small;
               color: red;
       }

Pretty simple, but let’s say that I wanted to change the word "IUBAT" to green bold text, while
leaving the rest of the sentence untouched. I would do the following to my HTML file.

       <p >
       I read in BSEEE and i am a student of
               <span class ="green-bold-text"> IUBAT. </span>
       The campus of this university is very nice.
       </ p>

Then in my CSS file I would add this style selector:

       .green-bold-text {
               font- size: big;
               color: green;
               font- weight: bold;
       }

The final result would look like the following:

I read in BSEEE and i am a student of IUBAT. The campus of this university is very nice.

                                                  .
Please note that a class selector begins with a “ ” period. The reason I named it "green-bold-
text" is for example purposes, you can name it whatever you want. Though, I do encourage you
to use selector names that are descriptive. You can reuse the "green-bold-text" class as many
times as you want.
CSS IDs:
        IDs are similar to classes, except once a specific id has been declared it cannot be used
again within the same HTML file. I generally use IDs to style the layout elements of a page that
will only be needed once, whereas I use classes to style text and such that may be declared
multiple times. The main container for this page is defined by the following.

       <div id ="container">
       Everything with in my document is inside this division.
       </div >

I have chosen the id selector for the "container" division over a class, because I only need to use
it one time within this file. Then in my CSS file I have the following:

       #container {
              width: 80% ;
              margin: auto;
              padding: 20px ;
              border: 1px solid #666000;
              background : #ffffff;
       }

You will notice that the id selector begins with a “#” number sign instead of a “.” period, as the
class selector does.

CSS Divisions:
        Divisions are a block level HTML element used to define sections of an HTML file. A
division can contain all the parts that make up your website. Including additional divisions,
spans, images, text and soon. You define a division within an HTML file by placing the following
between the <body></body> tags:

       <div>
                Site contents go here
       </div>

Though most likely you will want to add some style to it. You can do that in the following
fashion: The CSS file contains this:

       #container {
              width : 70% ;
              margin: auto;
              padding: 20px ;
              border: 1px solid #666000;
              background: #ffffff;
       }

And in the HTML file contains this:

       <div id ="container">
               Site contents go here
       </div>
Now everything within that division will be styled by the "container" style rule, I defined within
my CSS file. A division creates a line-break by default. You can use both classes and IDs with a
division tag to style sections of your website.

CSS Spans:
       A span is used to call a class from CSS files. Spans are very similar to divisions except
they are an inline element versus a block level element. No line-break is created when a span is
declared. You can use the span tag to style certain areas of text, as shown in the following:

        <span class= "italic" >this text is italic. </span>

Then in my CSS file:

        .italic {
                    font- style: italic ;
        }

The final result is:
       This text is italic.


CSS Margins:
       As you may have guessed, the margin property declares the margin between an HTML
element and the elements around it. The margin property can be set for the top, left, right and
bottom of an element.
See example below:

        margin-top : length percentage or auto;
        margin-left: length percentage or auto;
        margin-right: length percentage or auto;
        margin-bottom: length percentage or auto;

As you can also see in the above example you have 3 choices of values for the margin property
length percentage auto, you can also declare all the margins of an element in a single property as
follows:

        margin: 10px 10px 10px 10px;

If you declare all 4 values as I have above, the order is as follows:
        1. top
        2. right
        3. bottom
        4. left

If only one value is declared, it sets the margin on all sides.
Like:
        margin: 10px;



If you only declare two or three values, the undeclared values are taken from the opposing side.
Like:
        margin: 10px 10px;       / * 2 values */

        margi n: 10px 10px 10px;          / * 3 values */

You can set the margin property to negative values. If you do not declare the margin value of an
element, the margin is 0 (zero).

        margin: -10px ;        / * negative value */
        margin: 0;             / * 0 (zero) value */

Note: You do not have to add px (pixels) or whatever units you use, if the value is 0 (zero).

You can see in the example below, the elements for this site is set to be 20px (pixels) from the
body

        body{
                margin: 20px;
                background : #eeeeee;
                font- size: small;
                font- family: Tahoma, Arial, "Trebuchet MS ", Helvetica , sans-serif ;
                text- align: left;
        }


CSS Padding:
        Padding is the distance between the border of a HTML element and the content within it.
Most of the rules for margins also apply to padding, except there is no "auto" value, and negative
values cannot be declared for padding.

        padding -top : length percentage;
        padding -left: length percentage;
        padding -right: length percentage;
        padding -bottom: length percentage;

As you can also see in the above example you have 2 choices of values for the padding property
length percentage. You can also declare all the padding of an element in a single property as
follows:

        padding: 1 0px 10px 10px 10px ;

If you declare all 4 values as I have above, the order is as follows:
        1. top
        2. right
        3. bottom
        4. left


If only one value is declared, it sets the padding on all sides. Like:
        padding: 10px ;
If you only declare two or three values, the undeclared values are taken from the opposing side.
Like:

       padding: 10px 10px ;                   /* 2 values * /
       padding: 10px 10px 10px ;              /* 3 val ues * /

You can set the padding property to negative values. If you do not declare the padding value of
an element, the margin is 0 (zero).

       padding: -10px ;       / * negative value */
       padding: 0;            / * 0 (zero) value */

Note: You do not have to add px (pixels) or whatever units you use, if the value is 0 (zero).

You can see in the example below, the main container for this site has 30px (pixels) of padding
between the border and the text.
       #container {
               width : 7 0% ;
               margin: auto;
               padding: 30px ;
               border: 1px solid #666;
               background: # ffffff;
       }




                                                                            Continue…………..

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Web Typography
Web TypographyWeb Typography
Web Typography
 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Css ppt
Css pptCss ppt
Css ppt
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Images on the Web
Images on the WebImages on the Web
Images on the Web
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
Concept of CSS unit3
Concept of CSS unit3Concept of CSS unit3
Concept of CSS unit3
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Introducing Cascading Style Sheets
Introducing Cascading Style SheetsIntroducing Cascading Style Sheets
Introducing Cascading Style Sheets
 
CSS Foundations, pt 1
CSS Foundations, pt 1CSS Foundations, pt 1
CSS Foundations, pt 1
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
CSS
CSSCSS
CSS
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Css tutorial 2012
Css tutorial 2012Css tutorial 2012
Css tutorial 2012
 
Cascading Style Sheets - CSS - Tutorial
Cascading Style Sheets - CSS  -  TutorialCascading Style Sheets - CSS  -  Tutorial
Cascading Style Sheets - CSS - Tutorial
 

Destaque

How do we analyse film
How do we analyse filmHow do we analyse film
How do we analyse filmPaigeward96
 
Patent robin wu
Patent robin wuPatent robin wu
Patent robin wuhohooh0320
 
Effectiveness of freshman seminars and first year programs on[1]
Effectiveness of freshman seminars and first year programs on[1]Effectiveness of freshman seminars and first year programs on[1]
Effectiveness of freshman seminars and first year programs on[1]windstar2002
 

Destaque (7)

LA ECOLOGIA-BIOLOGIA 8
LA ECOLOGIA-BIOLOGIA 8LA ECOLOGIA-BIOLOGIA 8
LA ECOLOGIA-BIOLOGIA 8
 
Diary
DiaryDiary
Diary
 
How do we analyse film
How do we analyse filmHow do we analyse film
How do we analyse film
 
Genderrace justice
Genderrace justiceGenderrace justice
Genderrace justice
 
Patent robin wu
Patent robin wuPatent robin wu
Patent robin wu
 
Effectiveness of freshman seminars and first year programs on[1]
Effectiveness of freshman seminars and first year programs on[1]Effectiveness of freshman seminars and first year programs on[1]
Effectiveness of freshman seminars and first year programs on[1]
 
Manual de java 2
Manual de java 2Manual de java 2
Manual de java 2
 

Semelhante a Css

Semelhante a Css (20)

Css notes
Css notesCss notes
Css notes
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
INTRODUCTIONS OF CSS
INTRODUCTIONS OF CSSINTRODUCTIONS OF CSS
INTRODUCTIONS OF CSS
 
HTML to CSS Basics Exer 2.pptx
HTML to CSS Basics Exer 2.pptxHTML to CSS Basics Exer 2.pptx
HTML to CSS Basics Exer 2.pptx
 
Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
 
Css basics
Css basicsCss basics
Css basics
 
Css basics
Css basicsCss basics
Css basics
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentials
 
Css introduction
Css introductionCss introduction
Css introduction
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSS
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
WT CSS
WT  CSSWT  CSS
WT CSS
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layout
 
Chapter 3 - CSS.pdf
Chapter 3 - CSS.pdfChapter 3 - CSS.pdf
Chapter 3 - CSS.pdf
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and StyleLesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
 

Mais de Jahid Blackrose

Viyellatex MFP User Guide
Viyellatex MFP User GuideViyellatex MFP User Guide
Viyellatex MFP User GuideJahid Blackrose
 
How to install adobe dreamweaver 4
How to install adobe dreamweaver 4How to install adobe dreamweaver 4
How to install adobe dreamweaver 4Jahid Blackrose
 
Abdul haque dakau vs. the state
Abdul haque dakau vs. the stateAbdul haque dakau vs. the state
Abdul haque dakau vs. the stateJahid Blackrose
 
Abdul haque dakau vs. the state
Abdul haque dakau vs. the stateAbdul haque dakau vs. the state
Abdul haque dakau vs. the stateJahid Blackrose
 
Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]
Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]
Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]Jahid Blackrose
 
2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...
2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...
2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...Jahid Blackrose
 
Mosque and hr imran_shahriar_jahid
Mosque and hr  imran_shahriar_jahidMosque and hr  imran_shahriar_jahid
Mosque and hr imran_shahriar_jahidJahid Blackrose
 
Final presentation prepaid cards asia 2010
Final presentation   prepaid cards asia 2010Final presentation   prepaid cards asia 2010
Final presentation prepaid cards asia 2010Jahid Blackrose
 
Week3 task analysis_v1 (3)
Week3 task analysis_v1 (3)Week3 task analysis_v1 (3)
Week3 task analysis_v1 (3)Jahid Blackrose
 

Mais de Jahid Blackrose (15)

Hrsp User Manual
Hrsp User ManualHrsp User Manual
Hrsp User Manual
 
User manual HR portal
User manual HR portalUser manual HR portal
User manual HR portal
 
Viyellatex MFP User Guide
Viyellatex MFP User GuideViyellatex MFP User Guide
Viyellatex MFP User Guide
 
User guide
User guideUser guide
User guide
 
Mysql database make
Mysql database makeMysql database make
Mysql database make
 
How to install adobe dreamweaver 4
How to install adobe dreamweaver 4How to install adobe dreamweaver 4
How to install adobe dreamweaver 4
 
Dr a.p.m. sohrabuzzaman
Dr a.p.m. sohrabuzzamanDr a.p.m. sohrabuzzaman
Dr a.p.m. sohrabuzzaman
 
Abdul haque dakau vs. the state
Abdul haque dakau vs. the stateAbdul haque dakau vs. the state
Abdul haque dakau vs. the state
 
Abdul haque dakau vs. the state
Abdul haque dakau vs. the stateAbdul haque dakau vs. the state
Abdul haque dakau vs. the state
 
Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]
Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]
Brigadier (retd) a.h.m. abdullah vs. government of bangladesh and others [2001]
 
2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...
2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...
2 49-1316952140-mind map-for_academic_writing_-_a_tool_to_facilitate_universi...
 
Mosque and hr imran_shahriar_jahid
Mosque and hr  imran_shahriar_jahidMosque and hr  imran_shahriar_jahid
Mosque and hr imran_shahriar_jahid
 
Prepaid cards asia 2010
Prepaid cards asia 2010Prepaid cards asia 2010
Prepaid cards asia 2010
 
Final presentation prepaid cards asia 2010
Final presentation   prepaid cards asia 2010Final presentation   prepaid cards asia 2010
Final presentation prepaid cards asia 2010
 
Week3 task analysis_v1 (3)
Week3 task analysis_v1 (3)Week3 task analysis_v1 (3)
Week3 task analysis_v1 (3)
 

Último

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Último (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

Css

  • 1. CSS Basics-1 Mozahidur Rahman ‘Rousnay’ portfolio.rousnay.com facebook.com/rousnay admin@rousnay.com +01912671539 Introduction to CSS: A CSS (cascading style sheet) file allows you to separate your web sites HTML content from its style. As always you use your HTML file to arrange the content, but all of the presentation (fonts, colors, background, borders, text formatting, link effects & so on...) are accomplished within a CSS. At this point you have some choices of how to use the CSS, either internally or externally. All the various methods of stylesheet are used in the following order: 1. Internal Style Sheet (inside the <head> tag) 2. External Style Sheet 3. Inline Style (inside HTML element) Internal Style sheet: First we will explore the internal method. This way you are simply placing the CSS code within the <head></head> tags of each HTML file you want to style with the CSS. The format for this is shown in the example below. <html> <head > <title> </title> <style type= "text/css" > ……….CSS Content Goes Here…….. </style > </head> <body> …….your web site content goes to here…… </body> </html> With this method each HTML file contains the CSS code needed to style the page. Meaning that any changes you want to make to one page will have to be made to all. This method can be good if you need to style only one page, or if you want different pages to have varying styles. External Stylesheet: Next we will explore the external method. An external CSS file can be created with any text or HTML editor such as "Notepad" or "Dreamweaver". A CSS file contains no HTML, only CSS. You simply save it with the .css file extension. You can link to the file externally by
  • 2. placing one of the following links in the head section of every HTML file you want to style with the CSS file. <link rel= "stylesheet" type ="text/css" href ="http://www.rousnay.com/stylesheet.css"/> Either of these methods are achieved by placing one or the other in the head section as shown in example below. <html> <head > <title> </title> <link rel= "stylesheet” type ="text/css" href="http://www.rousnay.com/stylesheet.css"/> </head> <body> …….your web site content goes to here…… </body> </html> Inline Styles: I have not mentioned them until now because in a way they defeat the purpose of using CSS in the first place. Inline styles are defined right in the HTML file alongside the element you want to style. See example below. <p style=" color: #ff0000; "> Some red text </p > The final result is: Some red text CSS Syntax: The syntax for CSS is different than that of HTML markup. Though it is not too confusing, once you take a look at it. It consists of only 3 parts. In a typical CSS statement you have the following: SELECTOR {PROPERTY: VALUE } “PROPERTY" is the CSS element you wish to manipulate and "VALUE" represents the value of the specified property. The “SELECTOR” name creates a direct relationship with the HTML tag you want to edit. If you wanted to change the way a paragraph tag behaved, the CSS code would look like: p { PROPERTY: VALUE }
  • 3. Example: <html> <head> <style type="text/css"> p {color: red;} </style> </head> <body> <p>Example of CSS Selector! </p> <p>This paragraph is styled with CSS.</p> </body> </html> The final result is: Example of CSS Selector! This paragraph is styled with CSS. Each selector can have multiple properties, and each property within that selector can have independent values. The property and value are separated with a colon and contained within curly brackets. Multiple properties are separated by a semi colon. Multiple values within a property are separated by commas, and if an individual value contains more than one word you surround it with quotation marks. As shown below. body { background: # eeeeee; font- family: "Trebuchet MS", Verdana , Arial , serif; } As you can see in the above code I have separated the color from the Font-family with a semi- colon, separated the various fonts with commas and contained the "Trebuchet MS" within quotations marks. The final result sets the body color to light grey, and sets the font to ones that most users will have installed on their computer. Combining Selectors: You can combine elements within one selector in the following fashion. h1, h 2, h3 , h4, h5, h6 { color : # 009900; font- family: Georgia , sans-serif; } As you can see in the above code, I have grouped all the header elements into one selector. Each one is separated by a comma. The final result of the above code sets all headers to green and to the specified font. If the user does not have the first font I declared it will go to another sans- serif font the user has installed on their computer.
  • 4. CSS Comments: You can add comments that will be ignored by browsers in the following manner. /* this is a comment * / You will note that it begins with a / (forward slash) and then an * (asterisks) then the comment, then the closing tag which is just backward from the opening tag * (asterisks) then the / (forward slash). CSS Classes: The class selector allows you to style items within the same HTML element differently. Similar to what I mentioned in the introduction about inline styles. Except with classes the style can be overwritten by changing out stylesheets. You can use the same class selector again and again within an HTML file. To put it more simply, this sentence you are reading is defined in my CSS file with the following. p{ font- size: small; color: red; } Pretty simple, but let’s say that I wanted to change the word "IUBAT" to green bold text, while leaving the rest of the sentence untouched. I would do the following to my HTML file. <p > I read in BSEEE and i am a student of <span class ="green-bold-text"> IUBAT. </span> The campus of this university is very nice. </ p> Then in my CSS file I would add this style selector: .green-bold-text { font- size: big; color: green; font- weight: bold; } The final result would look like the following: I read in BSEEE and i am a student of IUBAT. The campus of this university is very nice. . Please note that a class selector begins with a “ ” period. The reason I named it "green-bold- text" is for example purposes, you can name it whatever you want. Though, I do encourage you to use selector names that are descriptive. You can reuse the "green-bold-text" class as many times as you want.
  • 5. CSS IDs: IDs are similar to classes, except once a specific id has been declared it cannot be used again within the same HTML file. I generally use IDs to style the layout elements of a page that will only be needed once, whereas I use classes to style text and such that may be declared multiple times. The main container for this page is defined by the following. <div id ="container"> Everything with in my document is inside this division. </div > I have chosen the id selector for the "container" division over a class, because I only need to use it one time within this file. Then in my CSS file I have the following: #container { width: 80% ; margin: auto; padding: 20px ; border: 1px solid #666000; background : #ffffff; } You will notice that the id selector begins with a “#” number sign instead of a “.” period, as the class selector does. CSS Divisions: Divisions are a block level HTML element used to define sections of an HTML file. A division can contain all the parts that make up your website. Including additional divisions, spans, images, text and soon. You define a division within an HTML file by placing the following between the <body></body> tags: <div> Site contents go here </div> Though most likely you will want to add some style to it. You can do that in the following fashion: The CSS file contains this: #container { width : 70% ; margin: auto; padding: 20px ; border: 1px solid #666000; background: #ffffff; } And in the HTML file contains this: <div id ="container"> Site contents go here </div>
  • 6. Now everything within that division will be styled by the "container" style rule, I defined within my CSS file. A division creates a line-break by default. You can use both classes and IDs with a division tag to style sections of your website. CSS Spans: A span is used to call a class from CSS files. Spans are very similar to divisions except they are an inline element versus a block level element. No line-break is created when a span is declared. You can use the span tag to style certain areas of text, as shown in the following: <span class= "italic" >this text is italic. </span> Then in my CSS file: .italic { font- style: italic ; } The final result is: This text is italic. CSS Margins: As you may have guessed, the margin property declares the margin between an HTML element and the elements around it. The margin property can be set for the top, left, right and bottom of an element. See example below: margin-top : length percentage or auto; margin-left: length percentage or auto; margin-right: length percentage or auto; margin-bottom: length percentage or auto; As you can also see in the above example you have 3 choices of values for the margin property length percentage auto, you can also declare all the margins of an element in a single property as follows: margin: 10px 10px 10px 10px; If you declare all 4 values as I have above, the order is as follows: 1. top 2. right 3. bottom 4. left If only one value is declared, it sets the margin on all sides. Like: margin: 10px; If you only declare two or three values, the undeclared values are taken from the opposing side.
  • 7. Like: margin: 10px 10px; / * 2 values */ margi n: 10px 10px 10px; / * 3 values */ You can set the margin property to negative values. If you do not declare the margin value of an element, the margin is 0 (zero). margin: -10px ; / * negative value */ margin: 0; / * 0 (zero) value */ Note: You do not have to add px (pixels) or whatever units you use, if the value is 0 (zero). You can see in the example below, the elements for this site is set to be 20px (pixels) from the body body{ margin: 20px; background : #eeeeee; font- size: small; font- family: Tahoma, Arial, "Trebuchet MS ", Helvetica , sans-serif ; text- align: left; } CSS Padding: Padding is the distance between the border of a HTML element and the content within it. Most of the rules for margins also apply to padding, except there is no "auto" value, and negative values cannot be declared for padding. padding -top : length percentage; padding -left: length percentage; padding -right: length percentage; padding -bottom: length percentage; As you can also see in the above example you have 2 choices of values for the padding property length percentage. You can also declare all the padding of an element in a single property as follows: padding: 1 0px 10px 10px 10px ; If you declare all 4 values as I have above, the order is as follows: 1. top 2. right 3. bottom 4. left If only one value is declared, it sets the padding on all sides. Like: padding: 10px ;
  • 8. If you only declare two or three values, the undeclared values are taken from the opposing side. Like: padding: 10px 10px ; /* 2 values * / padding: 10px 10px 10px ; /* 3 val ues * / You can set the padding property to negative values. If you do not declare the padding value of an element, the margin is 0 (zero). padding: -10px ; / * negative value */ padding: 0; / * 0 (zero) value */ Note: You do not have to add px (pixels) or whatever units you use, if the value is 0 (zero). You can see in the example below, the main container for this site has 30px (pixels) of padding between the border and the text. #container { width : 7 0% ; margin: auto; padding: 30px ; border: 1px solid #666; background: # ffffff; } Continue…………..