Hi All,

Just wondering... I have a chunk of code which is reused on many pages. The boss has just told me he wants the displayed elements to look slightly different on some pages. I've designed the HTML to be layout independent but I'd like to know your opinions...

Is it best practise to carry on reusing the same code using CSS to mash things up a bit (inc hiding certain elements) or simply recreate the code excluding these elements?

Try creating an external css file and link it to the page, and if there are any edits to specific elements within your code, just pop it into the HEAD section

Try creating an external css file and link it to the page, and if there are any edits to specific elements within your code, just pop it into the HEAD section

Thanks Monstette

What I've got at the moment resembles this..


Home Page HTML...

<div id="homePage">
	<div id="xsales">
		<div class="xsale">
			XSALE HTML
		</div>
	</div>
</div>

Product Page HTML...

<div id="productPage">
	<div id="xsales">
		<div class="xsale">
			XSALE HTML
		</div>
	</div>
</div>

and the CSS looks like this...

/* Standard xsale CSS */
#xsales {...}
#xsales div.xsale {...}

/* Homepage xsales */
#homePage #xsales {...}
#homePage #xsales div.xsale {...}

/* Productpage xsales */
#productPage #xsales {...}
#productPage #xsales div.xsale {...}

The thing I'm concerned about is using the same HTML for both pages as the pages will look very different and the CSS to change them around will be quite complex. I'm wondering whether its best to just restructure the HTML page instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.