Htmlandcsselements
Htmlandcsselements
Empty tags are tags which don't require closing tags. Some of them are:
<meta>, <link>
Whenever working on vscode, to link a css page, just write link and then press tab.
HTML elements like elements and headers are placed like boxes.
<section> can be used to create a section anywhere and you can add anything to it.
<footer> can be used to add a footer to the website. Here you can have contact
number, social media handles over here.
<aside> is a tag that can be used to put content which is not directly connected to
the main website content. This can be a side feature.
<main> is the container that is going to contain the main content of the page in
which the user is.
<div> describes nothing in the website. But this can be used to structure the
website better.
Don't use div tag everywhere. Use other tags for important content. Use div when it
is absolutely necessary.
to give your elements a distinct feature, you can make id's for them. These id's
will allow you to style only specific attributes and elements. and when you want to
style this, you can add the name and with a hashtag in the start and style it
accordingly. But the issue with id's is that you cannot use it in multiple
elements. Even though the desired result is seen, if you want to run this through a
website validator, it won't pass.
This is why we use classes. for class you simply write class before you want to
give it the name. And instead of giving a hashtag you give a full stop and then
write the class name. if you leave a space in your quotation marks for the class
name and write another name, you can add another styling to your element or
attribute.
images can be added in a variety of ways to your website. They can be added in a
container, normal way, or background.
IMG is a way to add the url for your image and alt is a way to name your image
whenever you want to differentiate it from other images. you can add a width and
height attribute within the image element. you can add images as a background and
write background size. your sizes can be written in percentages. if the image
duplicates itself multiple times, you can write background-repeat: no-repeat; and
if you want to prevent the duplication altogether, then you can write background-
size: cover; you can write background position if you want your image to be
centered by writing background-position: center;
if you want to add a hover image, go to CSS, whatever your class name is for your
image, add a colon, and add the pseudoelement hover in it. but there is an issue.
when you load the website and hover over the image for the first time, it will
flicker. so to remove this you can write a pseudoelement called after to pre load
the website. you can write content within the curly brackets and add the URL of the
image you want to add. but with this, you can by mistake add another image.
position: absolute; you can add width and height to 0. You can make an overflow as
hidden and the z-index as -1.
you can add a transition element in your hover effect here. you can write all.
Occasionally, you can write width or height. you can also write ease-in-out, ease-
out, or ease-in.
in your nav tag, you can make a ul(unordered list) tag for your buttons in it. then
you can add an li(list item) tag to add the names for your buttons. to link the
button to another page, you can add an anchor tag(<a> </a>) which will allow you to
add a button to the navbar along with the link to the other page.
If you want to add a hero section, which you will probably do, then you can use the
main tag. But if you think that this information is not important enough, then you
can add it in a section tag
css:
Whichever element you want to style, you can write its name and then put curly
brackets and write any css code you want to write in the curly brackets.
width and height can be used to size boxes in our website. You can put background-
color in these boxes as well.
Margins are spacing within different boxes in a website. you can have margines in
all of the directions. you can write only one margin element and then write four
values in this order, top,right, bottom, left
padding is the extra space within a container. padding is to create an outline for
your texts or images.
float is a way to make the text or any element move to any direction near any other
content in whichever direction you want it to go.
z-index can be used to position content wherever you want it to go. you can give a
number to it in order to move it whereever you want it to.
border can be given a color in order to outline different divs and images in order
to differentiate.
cursor element can make the cursor change whenever it hovers over an element.
display can make some elements disappear if you say none in it.
visibility can also be put at a setting of hidden
it is important to create a reset.css file before you start writing your css code.
this is because at times there might be issues with the fact there are some random
elements in your website which are unnecessary. So, a few websites are used for the
code they write to reset your website. This is called New CSS reset
flexbox:
this is another way to structure our content in a website
flexbox only works on content which is directy inside a header container
flex-direction allows you to change the way your content is placed next to each
other.
flex-wrap is a way to change the way your content wraps around in a line.
justify-content and align-content are ways to organize content in specific
containers
gap can be used to change the space between different content
order is a way to order your content in a specific container
flex-basis is another way to add width to your content. flex-basis is the basis of
the amount of minimum spacing required. we can tell the content to take over teh
remaining spacing if there is any
flex-grow can be used to takeover the remaining spacing
flex-shrink is a way to size your content according to the text which is in it
align-items is a way to align the items in a main container however you want it to
be
align-self is a way to align your content separately
to improve the look of the text in your website, you can use google fonts, download
a font which you like and add it in the website. this will allow using more
fonts.add the downloaded file to the root folder. before adding the font, you can
first add a link rel=preconnect href= https://fonts.google.com(or the link of the
site you sourced your font from). This will help you load the font faster. and then
add another preconnect in which you write https://gstatic.com in order to load the
fonts even faster.
in order to make your navigation bar sticky, you can put its position as fixed
the calc() function can be used to find out exact dimensions of objects and
elements in our websites by minusing pixels from percentages, viewwidth, viewheight
or any other measurement
in order to declare a variable, you need to add two dashes before you write the
variable name. this is the declaration for a variable. and after you do this, in
order to use the variable, you can write var() in any attribute and you are sorted.