Sunday, 22 October 2017

CSS-Multiple Selectors.

Multiple Selectors

In order to make CSS more concise, it's possible to add CSS styles to multiple CSS selectors all at once. This prevents writing repetitive code.
For instance, the following code has repetitive style attributes:
h1 { font-family: Georgia; } .menu { font-family: Georgia; }
Instead of writing font-family: Georgia twice for two selectors, we can separate the selectors by a comma to apply the same style to both, like this:
h1, .menu { font-family: Georgia; }
By separating the CSS selectors with a comma, both the h1 and the .menu elements will receive the font-family: Georgia styling.
Share:
Categories

CSS-Important.

Important

There is one thing that is even more specific than IDs: !important!important can be applied to specific attributes instead of full rules. It will override any style no matter how specific it is. As a result, it should almost never be used. Once !important is used, it is very hard to override.
The syntax of !important in CSS looks like this:
p { color: blue !important; } .main p { color: red; }
Since !important is used on the p selector’s color attribute, all p elements will appear blue, even though there is a more specific .main pselector that sets the color attribute to red.
The !important flag is only useful when an element appears the same way 100% of the time. Since it's almost impossible to guarantee that this will be true throughout a project and over time, it's best to avoid !important altogether. If you ever see !importantused (or are ever tempted to use it yourself) we strongly recommend reorganizing your CSS. Making your CSS more flexible will typically fix the immediate problem and make your code more maintainable in the long run.
Share:
Categories

CSS- Chaining and Specificity.

Chaining and Specificity

 This CSS selector was more specific than writing only h5. Adding more than one tag, class, or ID to a CSS selector increases the specificity of the CSS selector.
For instance, consider the following CSS:
p { color: blue; } .main p { color: red; }
Both of these CSS rules define what a p element should look like. Since .main p has a class and a p tag as its selector, only the p elements inside the .main element will appear red. This occurs despite there being another more general rule that states p elements should be blue.
Share:
Categories

CSS- Nested Elements.

Nested Elements

In addition to chaining selectors to select elements, CSS also supports selecting elements that are nested within other HTML elements. For instance, consider the following HTML:
<ul class='main-list'> <li> ... </li> <li> ... </li> <li> ... </li> </ul>
The nested <li> elements are selected with the following CSS:
.main-list li { }
In the example above, .main-list selects the .main-list element (the unordered list element). The nested <li> are selected by adding li to the selector, separated by a space, resulting in .main-list li as the final selector (note the space in the selector).
Selecting elements in this way can make our selectors even more specific by making sure they appear in the context we expect.
Share:
Categories

Saturday, 21 October 2017

JAVA- Operators.

Relational Operators

 Let's explore another set of useful operators available in Java known as relational operators.
Relational operators compare data types that have a defined ordering, like numbers (since numbers are either smaller or larger than other numbers).
Relational operators will always return a boolean value of true or false.
Here are a few relational operators:
  1.< : less than.
  2.<=: less than or equal to.
  3.>: greater than.
  4.>=: greater than or equal to.
  1. A relational operator is placed between the two operands(the terms that you want to compare using the relational operator). The result of a relational operation is printed out in the following statement:
System.out.println(5 < 7);
The example above will print out true because the statement "5 is less than 7" is true.

Equality Operators

You may have noticed that the relational operators did not include an operator for testing "equals to". In Java, equality operators are used to test equality.
The equality operators are:
  1. ==: equal to.
  2. !=: not equal to.
Equality operators do not require that operands share the same ordering. For example, you can test equality across booleanchar, or int data types. The example below combines assigning variables and using an equality operator:
char myChar = 'A'; int myInt = -2; System.out.println(myChar == myInt);
The example above will print out false because the value of myChar ('A') is not the same value as myInt ('-2').
Share:

JAVA- Math: +, -, *, and /.

Math: +, -, *, and /

Now let's try arithmetic in Java. You can add, subtract, multiply, and divide numbers and store them in variables like this:
int sum = 34 + 113; int difference = 91 - 205; int product = 2 * 8; int quotient = 45 / 3;

Math: %

 Let's explore one more special math operator known as modulo.
  1. The modulo operator - represented in Java by the % symbol - returns the remainder of dividing two numbers.
For example, 15 % 6 will return the value of 3, because that is the remainder left over after dividing 15 by 6.
Share:

JAVA-Comments.

Comments

comment is text you want Java to ignore. Comments allow you to describe code or keep notes.
By using comments in the Java code, you may help yourself and even other programmers understand the purpose of code that a comment refers to.
In Java, there are two styles of comments: single line comments and multi-line comments.
  1. Single line comments are one line comments that begin with two forward slashes:
// I'm a single line comment!
  1. Multi-line comments are generally longer comments that can span multiple lines. They begin with /* and end with */ . Here's an example:
/* Hello, Java! */
Share: