HTML CSS

HTML CSS

HTML  Style CSS

CSS stands for Cascading style sheets. It is used for adding different styles to elements in html. Html decides how to present the web page. Css decides the styles for the web page. Programmer can make the web page more presentable. CSS styling can be added to a web page in 3 ways:

A) Inline-Using style Attribute  in HTML Element.



B) Internal-Using Style Element in HTML head Section.


C )External-Using one or more external css files.



Normally in big websites they use external style sheets.

CSS Syntax

element {property:value;property:value}

Element is an html element on which we have to add different styles. This is also known as selector in css.

Property-property represents css property such as color,font-family etc.

Value-value represents css values.If multiple styles are there they are separated by a semicolon.

Inline Styling

Inline Styling is used for adding different css styles to elements in html.
Inline Styling use style attribute. Style attribute will be provided inside the starting tag of an element.
<h1 style=”color:red”>This heading is Red</h1>


Internal Styling


Internal Style sheet is provided in the head section of an html document. It is used to provide style to the whole document. In Internal Style sheet  css code is provided inside <style> tag.
<html>
<head>
<title>Internal styling</title>
<style>
h2{color:blue}
h4{color:red}</style>
</head>
<body>
</body>
<h2>Here we use internal styling</h2>
<h4>Color of this line is Red</h4>
</html>

Output

Internal styling

Here we use internal styling

Color of this line is Red

External Styling



External style sheets are used   when css styles are provided to many web pages.

The advantage of using external style sheet is that by changing one css file we could make changes to the entire site. External style sheets are linked to html pages in head section of the page.




CSS Fonts



There are certain css properties.Some of them are

Color-used to provide specified color  to html elements.
Font-family-this specifies the font to be used for displaying contents of html elements.
font-size-Specifies the size of html element.


 Id Attribute



Id element is used  to give names to html elements. To define a special style for a special element, first add an id attribute to the element.
<h1 id=”heading”>This heading has id</h1>

The class Attribute 

To define a style for a special type of elements, add a class attribute to the element. In Css we could select that element using the particular class name. id is used to address single elements and  class to address groups of elements.
<li class=”sample”>T</li>

0 Comment "HTML CSS"