Sunday, November 13, 2022

CSS Background propertie


 CSS Background propertie


CSS Background propertie

1. Properties

The CSS background properties are used to define the background effects for elements. To shorten the code, it is also possible to specify all the background properties in one single property. This is called a shorthand property.

Syntax:

 background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial | inherit;


1) Background  :-   Sets all the background properties in one declaration.

background-color,  background- image, background-repeat, background-attachment, background-position


2) background- attachment :- Sets whether a background image is fixed or scrolls with the rest of the page. 

scroll, fixed


3) background- color :- The background-color property specifies the background color of an element.

color-rgb, color-hex, color- name, transparent


4) background- image :- Sets the background image for an element.

url(URL)

5) background- position :- Sets the starting position of a background image.

top left, top center, top right, center left, center center, center bottom left, bottom center, bottom right, x% y%, xpos ypos

6) background- repeat :-    Sets how a background image will be repeated. 

repeat, repeat-x, repeat-y, no- repeat


2. Background-color Property

The background-color property sets the background color of an lement. The background of an element is the total size of the element, including padding and border Put not the margin). Use a background color and a text color that makes the text easy to read.

CSS Syntax:

 background-color: color / transparent | initial | inherit;

Property Values: 

Color

Specifies the background color. 


Transparent 

 This is the default value.Specifies that the background color should be transparent.

Initial 

Sets this property it's default value

Inherit  

Inherits this property from its parent element.


1. Background color 

Example 

<!DOCTYPE html>

<html>

<head>

<style>

body {

 background-color: rgb(180, 60, 50);}

h2 {

background-color:rgba(8, 150, 150, 10); } 

div { background-color:hsl (70, 45%, 45% ); } span{ background-color: yellow; }

</style> </head>

<body>

<h2>Welcome Pune Publication</h2> <div>Setting background color to "div"</div> <p>Setting <span> background color</span> to *p*</p>

</ul>

</body> 

</html>

Background color

 output

Background color


2.  Background color and image 

Example 

<!DOCTYPE html>

<html>

<head>

<style>

body {

  background-image: url("gradient_bg.png");

  background-repeat: repeat-x;

}

</style>

</head>

<body>

<h1>Hello World!</h1>

<p>Here, a background image is repeated only horizontally!</p>

</body>

</html>

 Background color and image

 output 


Background color and image

3. Linear gradient 

Using linear - gradient two colors as a background image for a <div> element. Internet 

Linear gradient 

Example 

<!DOCTYPE html>

 <html><head> <style>

 #bg1 { 

 height: 100px;

 background-color: #cccccc;

background-image: linear-gradient(red, yellow); }

#bg2 {

 height: 100px;

 background-color: #cccccc; 

background-image: linear-gradient(blue, red, green); 

}

 </style></head><body> 

 <h2>Linear Gradient</h2>

 <p>This linear gradient starts at the top. <br>It starts red, transitioning to yellow:</p>

 <div id="bg1"></div>

 <p>It starts blue, transitioning to red and red transforming to green:</p>

<div id="bg2"></div>

 </body>

 </html>

Linear gradient 

output 

Linear gradient

4. Linear Gradient as Background Image 

Example 

<!DOCTYPE html>

<html>

<head>

<Style>

#bg1 {

 height: 100px;

 background-color: #cccccc;  

background-image: repeating-linear-gradient(blue, green 10%, green 20%);

</style> 

</head>

<body>

<h2>Linear Gradient as Background Image</h2>

 <p>The repeating-linear-gradient() function is used to repeat linear gradients:</p> 

 <div id="bg1"></div>

 </body>

 </html>

Linear Gradient as Background Image

Output 

5. Radial gradient


Sets a radial gradient two colors as a background image for a <div> element use below code for two colors.


Radial gradient 

Example 

 <!DOCTYPE html> 

 <html>

<head>

 <style>

 #bg2 {

height: 200px; 

background-color: #cccccc; 

background-image: radial-gradient(red, yellow);

 </style> 

</head>

<body>

 <div id="bg2"></div>

<h2>Radial gradient</h2>

 </body> 

</html>

Radial gradient 

output 


Radial gradient


6. Repeating- linear- gradient

 Repeating linear gradient() function 

is used to repeat radial gradient.

Repeating- linear- gradient

 Example

<!DOCTYPE html>

 <html> 

<head> 

<style>

 #bg2 {

height: 200px;

background-color: #cccccc;

background-image: repeating-linear-gradient(yellow, red 10%, white 20%); 

</style> 

</head>

 <body> 

<h2> repeating linear gradient</2>

<div id="bg2"></div>

</body>

</html>

Repeating- linear- gradient 

output 

Repeating linear gradient



VISIT LINK

READ MORE 

Create Simple Feedback Form

background image with text

type of css



Saturday, November 12, 2022

CSS in combinators

 

  combinators in CSS 

combinators in CSS


1. Descendant selector  


Descendant selector (space) matches all the elements that are descendants of a specified elements, it means that selectors can select element that are descendants of others selector. The element does not have to be a direct child, but rather any descendant down the line.


Syntax:

element1 element2

{

style_properties

}


Descendant selector

 Example 

<!DOCTYPE html>

<html>

<head>

<style>

 ol li { 

color: red;

 } 

 </style>

</head>

 <body>

<ol>

<li>Databases</li> <br>

<ul>

<li>Oracle/PLSQL</li> 

<li>SQL</li>

</ul>

<li>ASP.Net</li>

<li>Java</li>

</ol> </ul>

 </body>

 </html>

Descendant selector 

output 


Descendant selector tag use

Descendant selector 

Example 


<!DOCTYPE html>

<html>

<head>

<style type="text/css">

h1 em{

color: blue; 

}

ul.menu { 

padding:5; list-style:none; 

margin:5px;

 } 

ul.menu li {

 display:inline; 

}

ul.menu li a{ 

margin:8px; 

text-decoration:none;

 }

</style>

</head>

<body>

<h1>This is <em>Heading</em></h1>

<ul class="menu">

 <li><a href="#">Home</a></li>

<li><a href="#">About Us</a></li>

<li><a href="#">Sell</a></li>

 <li><a href="#">Contact</a></li>

</ul>

</body>

</html>


Descendant selector

 output 

Descendant selector Tag use

2. Child selector (>) 


This selector is used to match all the elements which are child of a specified element. In another word, The CSS child selector uses the > character to target an element that is a direct child of an element type.



Syntax:

element1 > element2 
{
 style_properties
 }

Child selector

 Example 


<!DOCTYPE html>

<html>

<head> 
<style type="text/css">

ol > li {

color: blue; 
padding:5px;

}

</style>

</head>
<body> 
<ol>

<li>jadhav Publication</li>

<ul>

<li>C Language</li>
<li>IT Tools</li> 
<li>Python</li>
</ul>

<li>www.jadhav.com</li> <li>www.W3C.com</li>

</ol>
</body>
</html>


Child selector 

output 

Child selector Tag use





3. Adjacent sibling selector (+) 


Adjacent sibling selector uses "+" sign to combine two sequences of simple selectors. It is a selector for separating two selectors and matches the second element only when it immediately follows the first element. In this case, both are the children of the same parent element. In another word, It is use to select HTML elements that are adjacent siblings of some other HTML element.


Syntax:

Element+ Element2 
style_properties
}

Adjacent sibling selector 

Example 


<!DOCTYPE html>
<html>
 <head>

<style type="text/css">
 
h2+ p {
text-align:center;
color: red;
 font-size: 25px;
}

ul.tbp + p {

color: green; 
text-indent. 180px;
}

h1{
Color:pink;
text-align: middle;
}
</style>
</head>
<body>
<h2>Welcome to Tbalaji Publication</h2> <p>We are giving the following items.....</p> <p>Some of our books are given below:</p>

<ul class="top"> 
<li>1-> Python</li>
<li>2-> IT Tools</li>
<>3-> C Language</li>
</ul>
<h1>That's Set</h1>

<p>Goto Our Next Page></p>

</body> 
</html>

Adjacent sibling selector 

output 

Adjacent sibling selector Tag use



General sibling selector (~)
 

  The general sibling combinator (~) separates two selectors and matches the second element only if it follows the first element (though not necessarily immediately) and both are children of the same element.

Syntax:

Former_Element- Target_Element {

style
}


General sibling selector

 Example 


<!DOCTYPE html>
<html>
<head>
<style>
div-p {
background-color: red; 
font-size: 20px;

}
</style>

</head>
<body>

<h2>Welcome to pune Publication</h2>
<div>
<p>Start Code section 1</p>
 <code>Write some code here</code> <p>End of code section 1</p>
</div>
<p>Start Code section 2</p>
 <code>Write some code here</code> 
</body>
</html>


General sibling selector

 output 

General sibling selector tag use


 VISIT LINK
 AND
FOLLOW
MY BLOGGER WEBSITE


html frame

How to add Image

responsive image grid







Friday, November 11, 2022

Type of CSS Selectors

 Types of CSS selectors

Type of CSS selectors


 Type 

1. Universal Selector 

 2. ID Selector 

3. Tag Selector

4. Class Selector 

 5.Attribute Selector


1. Universal Selector 

The universal selector, written as i.e. asterisk or star symbol, matches every single element on the page. It is used for selecting all elements on a page. The universal selector may be omitted if other conditions exist on the target element. This selector is often used to remove the default margins and paddings from the elements for quick testing purpose.


Syntax:

*{

style properties

}

Universal Selector 

Example 

<!DOCTYPE html>

 <html> 

<head>

 <style>

*{

 color: green; 

font-size: 20px;

}

</style>

</head> 

<body>

 <h2> Universal Selector</h2>

 <p> This style will be applied on every paragraph.</p> 

 <p id="para1">Second Paragraph</p>

 <p>and Third Paragraph</p>

 </body> 

</html>

Universal Selector 

output 

Universal Selector tag use


2. ID selector 

This selector is used to select the id attribute of an HTML, element for selecting the specific element An id is always unique within the page so it is chosen to select a single, unique element. To select a element with a specific id, write a hash character, followed by the id of the element

What's special about ID styles is that they should be used only once per page. ID selectors are great for creating page layouts where you want to define each section of a page only once; they are ideal for creating a CSS layout.


ID selector 

Example 

<!DOCTYPE html>

<html>

<head>

<style>

#id1{

color: red;

text-align: center;

}

</style>

</head>

<body>

<p id="id1">ID Selector</p>

<p>This paragraph is not Affected.</p>  

<p> id="id1">This paragraph is Affected.</p>

</body>

</html>

ID selector

 output 


ID selector tag




3. Tag Selector


The tag selector is used to redefine existing HTML tags. Select this option if you want to change the formatting options for an HTML tag, such as the <h1> (heading 1) tag or the <ul> (unordered list) tag. In many cases, redefining existing HTML tags with CSS has advantages over creating new styles.


Tag Selector 

Example 

<!DOCTYPE html>

<html>

<head>

<style>

P{

text-align: center;

color: red;

}

h1{

color:blue;

text-align:center;

}

</style>

</head>

<body>

<h1> Tag Selector</h1>

<p>Every paragraph will be affected by the style.</p>

<p>Welcome</p> 

<h1> Every Heading Element<br> will be affected  </h1>

</body>

</html>

Tag Selector 

output 


Tag attributes use html



4. Class Selector 


It is used to define any HTML element which has the class attribute's. The element having that class will be formatted / style according to the given rule. It can be defined by using "" (full stop) symbol along with the class name.

Syntax:

class_name

{

style properties

}

Class Selector

 Example 

<!DOCTYPE html>

<html>

<head>

<title>Class Selector</title>

 <style type="text/css">

P.abc {

color:red;

text-align: center;

}

</style>

</head>

<body>

<h1 class="abc">This is Heading </h1> <p class="abc">First Paragraph</p>

<p class="abc">Second Paragraph</p>

</body> 

</html>

Class Selector

 output 



Class Selector

class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.

Class Selector 

Example 

<!DOCTYPE html>

<html>

<head>

<style>

.intro {

  background-color: yellow;

}

</style>

</head>

<body>

<h1> class selector</h1>

<div class="intro">

<p>My name is Donald.</p>

  <p>I live in Americap.</p>

</div>

<p>My best friend is Mickey.</p>

<p class="intro">My best friend is Mickey.</p>

</body>

</html>


Class Selector

 output 

Class Selector tag use

5. Attribute Selectors

HTML elements could be styled based on the presence of an attribute using the Attribute selector. For example below declaration would add border to any element with disabled attribute.


Attribute Selectors

 Example 

<!DOCTYPE html>

<html>

<head>

<style>

a{

  background-color: yellow;

}

</style>

</head>

<body>

<h2>CSS attribute Selector</h2>

<p>The links with a target attribute gets a yellow background:</p>

<a href="https://www.w3schools.com">w3schools.com</a>

<a href="http://www.google.com" target="_blank">Google.com</a>

<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>

</body>

</html>

Attribute Selectors

 output 


Attribute Selectors Tag

Visit link

Type of CSS Selectors

CREATE SIMPLE Feedback Form

css-background-propertie

background-image-with-text