Tech Coding Q&A

That is exactly the same as the first code I posted, which I noted was valid, though? I am asking why it is valid there, but not within body. Closing that bracket ends my declaration for body, meaning that declaring it outside while remaining within the head is, indeed, making it global. Correct?

If so, placing them within body, on the other hand, would "practically" be assigning it as a global, without literally doing so, is what I am thinking.

Simply put, it seems like quite the opposite of what you said, and I cannot assign local variables for different elements.

and I do hope I'm not coming off as a cunt, I'm just failing to make connections. It doesn't seem to make sense to me. :ffs:


Edit: Although it did not answer my question, your first example code gave me an idea. Thanks. ;)

1. CSS doesn't nest in the way that programming languages do. Having a CSS <body> tag begin with a bracket doesn't imply the opening brace { is the same as the brace in a function declaration. In CSS, body and a:link are individual objects. Nesting one inside the other doesn't work from a hierarchy perspective. It should be:

body { css goes here; }
a:link { css goes here; }

Nesting one inside the other is a no-go.

For things like divs, its like this:

.random_div { css goes here; }
.random_div a:link { css goes here; }

The a:link and the a:link declared as a subset of .random_div both have a different scope.

If there's text encapsulated within a div: <div class="random_div"> -text, text, text- </div> its local and separate from the main a:link.

2. Declaring things within <head></head> does nothing to make things global. The reason for putting code in <head> has to do with order of operations. The <head> area is the first thing that is loaded in a html document when the page loads. Placing your style or code there ensures its loaded before everything else.

3. No worries, no one starts out knowing everything. :elmo:

.
 
Been trying to catch up on all this, but I'm back. If you ever downloaded VS 2010 express (Free) you can actually create CSS style sheets and link them to a master page. A master page is used mostly to keep a constant between a few pages, such as the top logo, Menu sets and other fun stuff at the top or side of your pages. With a site master you can go nuts as well, and create a nice CSS for it, for you to create your pretty little margins, your padding as needed, and your content where each of the normal pages will be able to fill out the body. In the body of your normal pages you can declare the ID of the element you are working in, and since the site master is linked to the page, it will go and fetch the HTML from the CSS and style whatever style that id is. From a table to a grid to whatever else you had in mind.

For example:

Sitemaster.aspx (in my default directory) - I'll usually create this first with limited info in it.
MainStyles.css (in my default/style directory)
Default.aspx (my home page which people actually see)

In the sitemaster I'll refer back to my MainStyles.css. I'll build out my MainStyles around maybe a custom template at start, or a template I've created back when I was in school. I'm no designer, so I don't exactly have a HUGE proficiency in styling, but I can make margins/columns/tables/padding with neat little cell spacing to make sure the pages look tidy.

In the sitemaster I'll also establish my jquery. Jquery is awesome in combination with styling, because it let's you do some custom ajax which most other languages are dumb about. For instance Hover Menu sets, when you drag your mouse above a menu, it'll drop down etc. You can also do sliders and stuff too, which I've never really used, due to my boss of bosses, has governed parameters we must use.. and we can't get to fancy and one up each other.

If you don't know Jscript, learrrrrrrrrn it first. Take a few online tutorials everything is on Google. EVERYTHING.

So back to the sitemaster.. so I'll make sure the CSS is pretty, and then I'll start creating my objects and stuff with ID's I'll associate back to the CSS. For instance if I'm doing a header and I want it in a <div> or a header class.. I'll do something like <h1> and make sure in the CSS file the h1 is styled to my liking. If I want my column a certain width on each side and my footer to have my contact info, I'll touch it up there to.

For Divs, I'll generally do something like:

<div id = "Main"> Blah blah blah </div>

In the CSS I'll go back and put some styling for that div, for screen positioning (absolute, relative, fixed), width, padding, borders, font styling, etc. So that in that block of html, it resembles exactly what I want out of it.

So that's all I got for now.
 
Back
Top