Jump to content

Div HTML/CSS?


eduard

Recommended Posts

What I don´t understand is if you have divs in your html doc., how to you use them in CSS (external sheet)?

Link to comment
Share on other sites

Just do some research, please.It's right in the CSS tutorial on this page: http://w3schools.com/css/css_syntax.aspYou should be able to figure it out from there.EDIT: And the very next page shows you how to use ids (which answers your last question) and classes to style elements, which you'll need to learn how to use, because without those you'll be targeting every div on the page.

Link to comment
Share on other sites

Just do some research, please.It's right in the CSS tutorial on this page: http://w3schools.com/css/css_syntax.aspYou should be able to figure it out from there.EDIT: And the very next page shows you how to use ids (which answers your last question) and classes to style elements, which you'll need to learn how to use, because without those you'll be targeting every div on the page.
This I know! But that isn´t my question! If you have a div in your html doc., how do you refer=write it in your CSS? Sorry, I missed the 2nd part!
Link to comment
Share on other sites

This I know! But that isn´t my question! If you have a div in your html doc., how do you refer=write it in your CSS? Sorry, I missed the 2nd part!
That is the answer. You use either the generic div { /* css code /* } selector, or an ID or class. Just like he told you. what exactly don't you get?
Link to comment
Share on other sites

That is the answer. You use either the generic div { /* css code /* } selector, or an ID or class. Just like he told you. what exactly don't you get?
What I don´t understand exactly:In html you write: <div> </div>In css: .div or div class?
Link to comment
Share on other sites

In your HTML

<div class="myClass"></div>

In your CSS

.myClass {height: 90px; }

Or use an ID for a unique element

<div id="myID"></div>

#myID {height: 90px; }

Here's how to refer to all divs on the page

<div></div>

div {height: 90px; }

Link to comment
Share on other sites

What I don´t understand exactly:In html you write: <div> </div>In css: .div or div class?
like is explained in the tutorialsto use a class, you give the element a class in the HTML, and define the class in the CSS
HTML<div class="aClass"></div>CSS.aClass{  width: 500px;  background-color: blue;}

ID's are the same thing, except you can only have one element on the page with an ID, unlike class which you can have multple instances of in an HTML document

HTML<div id="aID"></div>CSS.aID{  width: 500px;  background-color: blue;}

or target ALL div, regardless of class/id, etc

CSSdiv{  width: width: 500px;  background-color: blue;}

you can be as generic or specific with your classes as you want. for example, you can specify only the particular elements that should be styled with a certain class

div.aClass{  width: 500px;  background-color: blue;}/* only div's with class aClass will 'show off' the styles */

Link to comment
Share on other sites

In your HTML
<div class="myClass"></div>

In your CSS

.myClass {height: 90px; }

Or use an ID for a unique element

<div id="myID"></div>

#myID {height: 90px; }

Here's how to refer to all divs on the page

<div></div>

div {height: 90px; }

Ok. thanks!
Link to comment
Share on other sites

like is explained in the tutorialsto use a class, you give the element a class in the HTML, and define the class in the CSS
HTML<div class="aClass"></div>CSS.aClass{  width: 500px;  background-color: blue;}

ID's are the same thing, except you can only have one element on the page with an ID, unlike class which you can have multple instances of in an HTML document

HTML<div id="aID"></div>CSS.aID{  width: 500px;  background-color: blue;}

or target ALL div, regardless of class/id, etc

CSSdiv{  width: width: 500px;  background-color: blue;}

you can be as generic or specific with your classes as you want. for example, you can specify only the particular elements that should be styled with a certain class

div.aClass{  width: 500px;  background-color: blue;}/* only div's with class aClass will 'show off' the styles */

Ok, thanks!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...