Jump to content

Can I Use Different Style To <div>tags,that Had No Define "id" Or "class"


lovekit

Recommended Posts

My English Language Skill is too lowso I'll try to explain you as clear as I can------------------ This is Question ----------------------if I have a PHP page which used stylesheet.css file to adjust pageslike this

<html><head><title>some title</title><META http-equiv=Content-Type content="text/html; charset=tis-620"><LINK href="/view.css" type=text/css rel=stylesheet></head><body>	 Here is where content placed	 <div>		  content in div 1	 </div>	 <div>		  content in div 2	 </div>	 <div>		  content in div 3	 </div>	 <div>		  content in div 4	 </div>	 <div>		  content in div 5	 </div></body></html>

And this is list of Questions<1.> can I edit style to each <div>tags with no "ID" or "Class" like this sample code to be different looks ? - for Eg. content in div 1 difference to content in div 2 and 3 and 4 and 5 (Difference them all) ?<2.> if it's possible, Where can I finds the "how to". And how can I do it without editing main page? (just use stylesheet :Eg. view.css to adjust it)<3.> Have other script or code such as JAVASCRIPT AJAX ETC. can do this?<4.> if i want to insert more <META>tag or <LINK>tag in <head> without editing main page, Is it possible?<5.> from Q:<4.> Which process can make it possible ?Thank you.if you don't understand my Questionsplease leave a replyPS. My English skill is not so good

Link to comment
Share on other sites

You can use javascript to loop through the divs and change their style depending on the order they appear in the page. You would probably be best storing an array of styles. It will take a fair amount of code. Can you use jQuery?

Link to comment
Share on other sites

<1> You can, but it involves a selector (the adjacent selector) that older versions of IE don't support. Depending on your code, you may also need to use the child selector, again unsupported. E.g. (untested):

body > div { /* div 1 */ }body > div + div { /* div 2 */ }body > div + div + div { /* div 3 */ }/* etc. */

<2> Just insert it down the bottom of view.css<3> The other way, yes, is to use JS to iterate through the elements on the page and change them conditionally.<4> No, but with certain types of servers you can use config files (e.g. .htaccess) to insert additional true headers.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...