Here in CSS, we get a target and pick up that specific element which we want to work on, from the web page.
CSS has mainly 2 parts, that is to say;
Inline CSS
* Here, CSS is used within the target element. * For example:`<p color="white"> This is inline CSS </p>`
Internal CSS
* Here, CSS is written within the html file above the body tag and within the head tag. * This is done with the help of `<style>` tags.
External CSS
For this case, CSS file is linked to the index.html file.
When compiling the CSS code, CSS also bases on priority. In such case, inline CSS always has the highest priority, followed by internal CSS then external CSS.
The following are some of the common CSS selectors used.
Universal Selector: When such selector is used, everything in the html file (all the html tags) is targeted or selected.
For example:
*{
background-color: grey
}
This means that all the webpage will have a background color of grey
Individual Selector
targets all paragraphs in the index.html accordingly.
Class and Id Selectors
For example;
.warning{
align items: center;
}
An id name should not be applied or used multiple times, although, even when you do so, there would be no error thrown in our file during compilation. But this would be a bad coding practice.
Yet for a class name, you can use the same name multiple number of times .
Child Selector
We also have other selectors
The most commonly used selectors are the class and id selectors
When using colors for CSS, it is always best practice to use standard color codes (like #4d4d4d) unlike word colors like red or green.
This is because, different browsers view the colors in different ways, but if color codes are used, this acts like a standard overall color which is viewed as the same color even in different browsers.
Note: We only apply FOCUS to input tags.
Absolute;
- This gives position of the target depending on the parent webpage, that is, border of the whole web page.
Relative;
- This gives position to the target element depending on the body or boxes in which the current target is ,that is, depending on the original position of the target.
Sticky;
- This gives position to the target, and after this, it will not move to another position.
Fixed;
- After applying this, the target won't be changed or modified. It would be in this position fixed as it had been allocated.
When flex is applied, it means that the target elements can be placed in only one horizontal dimension.
Incase we want dynamic display, this is where we can use grid.
We use CSS to modify our webpages as it helps us to easily style our text.
The above is the detailed content of VANILLA CSS BASICS YOU SHOULD KNOW. For more information, please follow other related articles on the PHP Chinese website!