4

I am attempting to ask a more specific question than "how does browsers work??", please bear with me :)

If I understand correctly, html elements may have some default properties that determine their behavior. For example, <div> has display: block property set by default, while span has display: inline

These defaults exist because they are defined in the browser's default stylesheet.

Ok cool, I get that (hopefully). But what about <br /> or <img>? The behavior of those is determined by more than their properties right? Is it just up to the browser's implementation to make them behave how the W3 html5 specification says they should?

Also, is there an official word for this kind element behavior or does it just fall under 'browser implementation'?

matt
  • 350
  • 1
  • 6
  • Default properties became more complex in HTML5. Elements can now fall into multiple (or even none) [content categories](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories). – marked-down Nov 18 '14 at 20:38

2 Answers2

1

So, you're really asking two questions here:

  1. What is the default presentation and behavior of HTML elements?
  2. Who/what determines how this works in a browser?

Let's start with question 2

The HTML specification is written and reviewed by a group within the W3C called the HTML Working Group. When they've agreed on a specification they publish it as a Recommendation. You can read the HTML 5 spec here, but I don't recommend reading the whole thing - it's very long and boring full of technical jargon.

However, the W3C's recommendation defines only the syntax and intended purposes of the features of HTML - it does not define how browsers should render HTML. Browser vendors, like Microsoft (IE), Mozilla (FireFox), Apple (Safari), and Google (Chrome), get to determine how their browsers render and implement the features of HTML.

Fortunately, most of the common HTML elements behave almost exactly the same from browser to browser. It's in the vendor's best interests to stay consistent among each other, because if one of them decided to do something drastically differently from all the others, the people who build websites would have to spend more time supporting that specific browser and it would fall out of favor (as was the case with IE 6 up until IE 11).

What determines the behavior of HTML elements?

The browser's rendering engine. Some browsers share the same rendering engines (like Safari and Chrome) (not true anymore - see comments), but not all. This article offers some insights (and leads to more insights) about how browsers are built, and here's an article listing several browser engines.

For the most part, you can affect how your HTML document looks by changing its CSS properties, but the behavior of most HTML elements is unchangeable without scripting using JavaScript.

The default CSS styles applied by your browser is defined by a stylesheet called its User Agent Stylesheet. These are usually pretty basic styles that browser vendors design in order to make HTML documents a little more readable without drastically affecting the presentation of the document.

However, there are so many basic styles applied by different browsers, that it's very common for web developers/designers to what's called a CSS reset. Normalize.css is a great example of this, and it's one of the most popular ones.

Community
  • 1
  • 1
Jerreck
  • 2,930
  • 3
  • 24
  • 42
  • 1
    Are you sure that Safari and Chrome share the same rendering engine these days? –  Nov 19 '14 at 03:27
  • Different JavaScript engine, but I'm pretty sure they both use WebKit for layout. – Jerreck Nov 19 '14 at 03:43
  • 1
    From Wikipedia article on Webkit: "WebKit is used as the rendering engine within Safari and was formerly used by Google's Chrome web browser." –  Nov 19 '14 at 04:10
  • That's interesting. So why do webkit vendor prefixes still work in chrome? – Jerreck Nov 19 '14 at 04:36
  • 1
    because they retained them for backward compatibility. –  Nov 19 '14 at 04:50
-1

I believe it is up to the browser implementation. The way it will appear on the screen is up to the browser implementation. Although, all browsers agree on how it should appear on screen. These standards are defined by the World Wide Web Consortium - (wikipedia).

I guess this information you are seeking can be found in these sites!