WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML Styles - CSS


CSS = Styles and Colors

Manipulate Text
Colors,  Boxes


Styling HTML with CSS

CSS full type of Cascading Style Sheets

We can Style HTML Page by adding to HTML components in 3 ways:

  • Inline - In this technique style attribute in HTML elements
  • Internal - In this technique <style> element in the HTML <head> section
  • External - In this technique at least one external CSS records, for example, .CSS augmentation

In this part we learn basic technique for Inline CSS


Inline Styling (Inline CSS)

Inline styling is utilized just extraordinary style to a solitary HTML element:

Inline styling utilizes the style attribute.

example content shade of the <h1> component to green:

Example

<h1 style="color:green;">This is a green Heading</h1>
Try it Yourself »

Internal Styling (Internal CSS)

It is an utilization style for one HTML page.

Internal styling can be use in the <head> area of a HTML page, inside a <style> element:

Example

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:lightgrey;}
h1   {color:red;}
p    {color:green;}
</style>
</head>
<body>

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

</body>
</html>
Try it Yourself »

External Styling (External CSS)

It is an utilization the style for some pages.

you can utilize outer template, add a connection to it in the <head> segment of the HTML page:

Example

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="styles.css">
</head>
<body>

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

</body>
</html>
Try it Yourself »

The record ought not contain any html labels. The template document must be spared with a .css extension.

Here is the manner by which the "styles.css" looks:

body {
    foundation shading: lightgrey;
}

h1 {
    shading: red;
}

p {
    color:green;
}

CSS Fonts

CSS color property depict content shading to be utilized for the HTML element.

CSS font-family property depict textual style to be utilized for the HTML element.

CSS font-measure property portray content size to be utilized for the HTML element.

Example

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
    shading: blue;
    textual style family: verdana;
    text dimension: 300%;
}
p  {
    shading: red;
    textual style family: courier;
    text dimension: 160%;
}
</style>
</head>
<body>

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

</body>
</html>
Try it Yourself »

The CSS Box Model

Every HTML component has a container around it, regardless of whether you can't see it.

The CSS border property characterizes a noticeable outskirt around a HTML element:

Example

p {
    outskirt: 1px strong green;
}
Try it Yourself »

The CSS padding property characterizes a cushioning (space) inside the border:

Example

p {
    outskirt: 1px strong black;
    cushioning: 10px;
}
Try it Yourself »

The CSS margin property characterizes an edge (space) outside the border:

Example

p {
    outskirt: 1px strong black;
    cushioning: 10px;
    edge: 30px;
}
Try it Yourself »

The id Attribute

Next step,we find out about id quality

id attribution is style for one element.:

<p id="p01">Never be the same</p>

eg. style for components with id

Example

#p01 {
    shading: green;
}
Try it Yourself »

The class Attribute

style for class of component we can include class attribute:

<p class="error">Never be the same</p>

we can utilize diverse style for components :

Example

p.error {
    shading: green;
}
Try it Yourself »

Chapter Summary

  • Use the HTML style property for inline styling
  • Use the HTML <style> component to characterize inside CSS
  • Use the HTML <link> component to allude to an outer CSS file
  • Use the HTML <head> component to store <style> and <link> elements
  • Use the CSS color property for content colors
  • Use the CSS font-family property for content fonts
  • Use the CSS font-size property for content sizes
  • Use the CSS border property for noticeable component borders
  • Use the CSS padding property for space inside the border
  • Use the CSS margin property for space outside the border


HTML Style Tags

Tag Description
<style> Defines style data for a HTML document
<link> Defines a connection between an archive and an outside asset