Css Basics - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Css Basics - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Tuesday, December 11, 2018

Css Basics

Css Basics



A CSS (cascading style sheet) file allows you to separate your web sites (X)HTML content from it's style. As always you use your (X)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.

Internal Stylesheet


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

<head>
<title><title>
<style type="text/css">
CSS Content Goes Here
</style>
</head>
<body>

With this method each (X)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 (X)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 (X)HTML file you want to style with the CSS file.

<link rel="stylesheet" type="text/css" href="Path To stylesheet.css" />
Or you can also use the @import method as shown below

<style type="text/css">@import url(Path To stylesheet.css)</style>
Either of these methods are achieved by placing one or the other in the head section as shown in example below.

<head>
<title><title>
<link rel="stylesheet" type="text/css"href="style.css" />
</head>
<body>

or

<head>
<title><title>
<style type="text/css"> @import url(Path To stylesheet.css) </style>
</head>
<body>

By using an external style sheet, all of your (X)HTML files link to one CSS file in order to style the pages. This means, that if you need to alter the design of all your pages, you only need to edit one .css file to make global changes to your entire website.

Selector  { property =  Value ;}


Selector = Allows you to select and manipulate HTML element(s).

Property = Identifies the property you want to manipulate.

Value = Defines the changes.


A SNIPPET THAT CONTROLS SIDEBAR ATTRIBUTES.

#sidebar { position: relative; float: left; width: 100px; color: red; font-size: 40%; border-left: solid 2px blue; }

Changes the variable inside the () to manipulate alignment,color,font size,and border width.

FONT SHORTHAND PROPERTY SET TO DEFINE ALL 

PROPERTIES IN ONE STATEMENT

#selector { font: italic bold 12px/30px Georgia, serif; }

Italic bond = Font-Style
12px = Font-size*
30px = line-height
Georgia, serif = Font-family*
*Font size and family are required, but other values will automatically set to default if excluded.  

No comments:

Post a Comment

Post Top Ad